jayfmil / miller_ecog_tools

7 stars 3 forks source link

read in old style localization information #4

Open jayfmil opened 6 years ago

jayfmil commented 6 years ago

For old rhino subjects without tal struct .mat files, read in the localization information from the available text files and convert to our standard elec_info dataframe format.

jayfmil commented 6 years ago

Electrode coordinate info in: /data/eeg/tal/allTalLocs_GM.mat

Also need to load in depth electrode info separately.

HonghuiZ commented 6 years ago

What's GM mean? I can only see some patients info there. For the newer patients the tal info is located at /data/eeg/patientName/tal/patientName_talLocs_database_monopol.mat or /data/eeg/patientName/tal/patientName_talLocs_database_bipol.mat For the old patients like CH or FR patients, the monopolar tal structure is generated through Josh's code and there're no bi-polar pairs.

jayfmil commented 6 years ago

Maybe "gold master", just meaning the final release version. The file has these subjects:

array(['BW001', 'BW003', 'BW004', 'BW009', 'BW013', 'BW014', 'BW022', 'BW023', 'BW024', 'BW025', 'CH001', 'CH003', 'CH004', 'CH005', 'CH007', 'CH008a', 'CH008b', 'CH009', 'CH011', 'CH012', 'CH013', 'CH017', 'CH018', 'CH020', 'CH023', 'CH024', 'CH040', 'CH042', 'CH046', 'CH048', 'CH057', 'CH058', 'CH061', 'CH063', 'CH064', 'CH065', 'CH066', 'CH067', 'CH068', 'CH069', 'CP006', 'FR011', 'FR012', 'FR013', 'FR014', 'FR015', 'FR017', 'FR018', 'FR019', 'FR021', 'FR025', 'FR026', 'FR027', 'FR028', 'FR029', 'FR032', 'FR037', 'FR038', 'FR040', 'FR050', 'FR060', 'FR070', 'FR080', 'FR090', 'FR100', 'FR110', 'FR120', 'FR130', 'FR140', 'FR150', 'FR160', 'FR170', 'FR180', 'FR190', 'FR191', 'FR192', 'FR193', 'FR194', 'FR195', 'FR196', 'FR200', 'FR210', 'FR220', 'FR230', 'FR240', 'FR250', 'FR260', 'FR270', 'FR280', 'FR290', 'FR320', 'FR330', 'FR340', 'FR350', 'FR360', 'FR380', 'FR390', 'FR391', 'FR400', 'FR410', 'FR420', 'NIH001', 'NIH003', 'NIH004', 'NIH005', 'NIH006', 'NIH007', 'NIH009', 'NIH011', 'TJ001', 'TJ003', 'TJ004', 'TJ005', 'TJ005_1', 'TJ006', 'TJ007', 'TJ008', 'TJ010', 'TJ011', 'TJ012', 'TJ013', 'TJ014', 'TJ015', 'TJ016', 'TJ017', 'TJ018', 'TJ018_1', 'TJ018_2', 'TJ019', 'TJ020', 'TJ021', 'TJ022', 'TJ023', 'TJ024', 'TJ025', 'TJ027', 'TJ028', 'TJ029', 'TJ030', 'TJ031', 'TJ032', 'TJ033', 'TJ034', 'TJ035', 'TJ036', 'TJ037', 'TJ037_1', 'TJ038', 'TJ038_1', 'TJ039', 'TJ040', 'TJ040_1', 'TJ041', 'TJ041_1', 'TJ041_2', 'TJ042', 'TJ043', 'TJ044', 'TJ045', 'TJ045_1', 'TJ046', 'TJ047', 'TJ048', 'TJ049', 'TJ050', 'TJ052', 'TJ053_1', 'TJ054', 'TJ055', 'TJ056', 'TJ057', 'UP001', 'UP002', 'UP003a', 'UP003b', 'UP004', 'UP005', 'UP006', 'UP007', 'UP008', 'UP010', 'UP011', 'UP012', 'UP013', 'UP014', 'UP015', 'UP016', 'UP017', 'UP018', 'UP019', 'UP020', 'UP021', 'UP022', 'UP023', 'UP024', 'UP025', 'UP026', 'UP028', 'UP029'], dtype=object)

which is most of pymms?

In any case, I think the steps should be:

  1. See if the patientName_talLocs_database_monopol.mat or bipol file exists. If it does, use that.
  2. If it doesn't, do what Josh's code does, which is to use the allTalLocs_GM file to get the x,y,z and some location information, and then it adds the depth info from either "depth_el_info.txt' or "hipp_only.txt".
HonghuiZ commented 6 years ago

Ha, I thought the each file name matching one patients instead of one file with all the information. So we do have everything for the old patients. I think Mike does take care of the most of the newer patients with patientName_talLocs_database_monopol.mat. (You have to use matlab_contacts or matlab_pairs for now). But for some patients, it is not working (try subjects[106]). Try the latest CML with following test

from cmlreaders import get_data_index, CMLReader r1_data = get_data_index(kind='pyfr') subjects=sorted(r1_data[r1_data['experiment']=='pyFR'].subject.unique()) reader = CMLReader(subjects[103], "pyFR") contacts = reader.load("matlab_contacts") print(contacts)

jayfmil commented 6 years ago

Ok nice. That basically does what my load_elec_info() does for subjects that aren't in the r1 protocol.

I'll work on implementing step 2 above in my RAM_helpers code now.

HonghuiZ commented 6 years ago

You code is amazing. I didn't know the RAM_helpers can do so much! I am not sure why the cmlreader fails for some subjects. Will contact them.

jayfmil commented 6 years ago

Thanks!

Do you know the best way to determine if an electrode for these older subjects is a grid, strip, or depth?

HonghuiZ commented 6 years ago

The montage field might be helpful. unique({events.montage})='', 'hipp', 'inf', 'lsag' , 'lsag_int', 'rsag', 'rsag_int' I don't know how to separate grids and strips, but the 'lsag' or 'rsag' are neocortical electrodes (strip or grid). I assume everything else are depth electrodes?
I will run some tests.

jayfmil commented 6 years ago

Oh right, that's a good point. I bet we'll be able to use that info. Let me know what you find out.

HonghuiZ commented 6 years ago

I think that's the only info for the older patients. The lsag and rsag are normal neocortical electrodes, and the ones with int are surface electrodes in the middle line. Inf and hipp are depth electrodes.

jayfmil commented 6 years ago

I updated load_elec_info to load in a bunch of this older info. I still need to have it read in the "neurorad_localization.txt" files, which exist for some patients and contain more precise localization info than "depth_el_info.txt".

But I think it is generally working. I just tried running a pymms subject with SubjectOscillationClusterAnalysis, and it seemed to be ok.