kylemath / pyoptical

Imagent optical imaging interface to MNE loading
MIT License
4 stars 1 forks source link

added file to test two methods to align coords #19

Closed kuziekj closed 4 years ago

kuziekj commented 4 years ago

added a file (coreg_fiducials_JK.py) to demonstrate two methods to align fiducials.

Method 1 -get fiducials from 'fsaverage' -uses 'coregister_fiducials()' function to create transformation matrix from the 'fsaverage' fiducials and the fiducials added to info struct -this transformation matrix is passed as the 'trans' argument to 'mne.viz.plot_alignment()'

Method 2 -similar to how info.dig is calculated in nirx.py -gets mri-to-head space transformation matrix for fsaverage using '_get_trans()' -applies this transformation matrix to all channel and fiducial coords using 'apply_trans()' -'trans='fsaverage'' is passed to 'mne.viz.plot_alignment()'

should note that info only contains coordinates for info.dig channels when creating the info struct, channels must be specified as 'eeg' type or else they won't plot not sure why this is, especially since 'nirx.py' specifies the channels as 'fnirs_raw' and they plot just fine. May be because only info.dig coordinates are included in my example file.

kylemath commented 4 years ago

0:18 it runs on my machine

just need to fix two lines so they work on windows and mac you can use

import os
then os.path.join(path, ‘folder’, ‘folder’, ‘file.ext’) 

to make paths that are agnostic to which os you are using I bet you have seen that style in the mne tutorials also good to use “relative paths” relative to the folder the person is in

so you had import pyoptical.utils but I was already in the pyoptical folder so that didn’t work

kylemath commented 4 years ago

Ill fix these things and push my chages @kuziekj

kylemath commented 4 years ago

so is the difference in the second example that they compute and apply the coordinate transform to the points prior to loading them into the info structure and then just plot the overlapping points without having to do the co registration

if so I prefer the first example as it's more similar to the examples on the internet from Mne

kuziekj commented 4 years ago

yeah so in nirx.py, it looks like it's getting the transform for 'fsaverage' and then applying that transform to the source, detector, and channel coordinates from the loaded data file.

it then gets the fiducials from 'fsaverage' to create the digitisation object, places the transformed channel coordinates in that object, and then adds the object to info.

so yes, as far as I can tell nirx.py isn't doing any co-registration. I find it strange because it seems like the tranform it creates is specific to 'fsaverage' and not the data that is being loaded. Maybe I'm wrong about that though...

kylemath commented 4 years ago

hmmmm, sooo thinking about the nirx function, it basically spits out the same thing ours does, but already transformed without the trans object included. At it transforms everyone into the same fsaverage space like we wanted to do, I do like our way better but maybe there was a reason they did it this way