Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for KIT data and FastSCAN head digitization #264

Open
DJayalath opened this issue Feb 5, 2024 · 0 comments
Open

Support for KIT data and FastSCAN head digitization #264

DJayalath opened this issue Feb 5, 2024 · 0 comments

Comments

@DJayalath
Copy link

I was trying to load the following dataset: https://www.nature.com/articles/s41597-023-02752-5 and realised that OSL does not support this KIT dataset with .con MEG data files.

This can be supported using https://mne.tools/dev/generated/mne.io.read_raw_kit.html

However, this particular dataset has FastSCAN files (.pos) for ELP and HSP data. read_raw_kit does not support this file type in the elp= and hsp= arguments. The arrays cannot be loaded directly with https://mne.tools/dev/generated/mne.channels.read_polhemus_fastscan.html either because it only supports .txt files. This also fails after converting the file type. I had to use np.loadtxt with comments=% to load the .pos files and pass the arrays directly to the elp= and hsp= arguments of read_raw_kit.

This worked but led to an OOM error. This was because the FastSCAN files had positions in mm rather than m. MNE decimates HSP arrays with more than 10k points with a voxel size of 0.005. Since very large numbers were passed (in mm) this led to an out of memory error when computing the 3D histograms for decimation with a very small voxel size. So I also had to divide the ELP and HSP arrays by 1000 to get the correct unit expected by MNE.

My solution for this particular dataset was:

logger.info(
    "Detected Ricoh/KIT file format, using: mne.io.read_raw_kit"
)
mrkfile = infile.replace("meg.con", "markers.mrk")

elpfile = infile.split("task")[0] + "acq-ELP_headshape.pos"
elp = np.loadtxt(elpfile, comments="%")
elp /= 1000.0 # Convert from mm to m otherwise decimation will be OOM

hspfile = infile.split("task")[0] + "acq-HSP_headshape.pos"
hsp = np.loadtxt(hspfile, comments="%")
hsp /= 1000.0 # Convert from mm to m otherwise decimation will be OOM

raw = mne.io.read_raw_kit(
    infile,
    mrk=mrkfile,
    elp=elp,
    hsp=hsp,
    preload=preload
)

I hope this helps in developing a more general solution for loading KIT data with the head digitization information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant