Skip to content

Conversation

@alexrockhill
Copy link
Contributor

The idea here is to find which voxels are nearby an electrode contact in order to know which surfaces to plot and for analysis.

This shares internal functions with #9544 and is a good reason to make mne.surfaces._find_voxel_neighbors private so that it can be used in both scenarios without confusion and user-facing function.

@alexrockhill
Copy link
Contributor Author

@larsoner, I think it might be best to change the default back to aseg.mgz because fsaverage doesn't have any other segmentations in the sample data.

@alexrockhill alexrockhill changed the title [WIP, ENH] Find aseg labels near montage [MRG, ENH] Find aseg labels near montage Jul 15, 2021
@alexrockhill
Copy link
Contributor Author

This is ready for review too, but this PR has to merge first mne-tools/mne-misc-data#9

@larsoner
Copy link
Member

Even after fetch_fsaverage is called?

We can also update the sample dataset pretty easily, so I wouldn't let it be a limiting factor

@alexrockhill
Copy link
Contributor Author

Even after fetch_fsaverage is called?

We can also update the sample dataset pretty easily, so I wouldn't let it be a limiting factor

Yes but good to know, maybe we should update that then

@alexrockhill
Copy link
Contributor Author

This also updates the seeg tutorial which was out-of-date because of the new data format

@alexrockhill
Copy link
Contributor Author

Here's what the plots I added look like by the way.

Screen Shot 2021-07-14 at 8 23 04 PM

@larsoner
Copy link
Member

I think it might be best to change the default back to aseg.mgz because fsaverage doesn't have any other segmentations in the sample data.

I just did mne.datasets.sample.data_path(force_update=True, verbose=True) (i.e., not even running fetch_fsaverage) and I see:

$ ls ~/mne_data/MNE-sample-data/subjects/fsaverage/mri
aparc.a2005s+aseg.mgz  aparc+aseg.mgz  brainmask.mgz  lh.ribbon.mgz   orig      p.aseg.mgz     ribbon.mgz        subcort.prob.mgz  transforms
aparc.a2009s+aseg.mgz  aseg.mgz        brain.mgz      mni305.cor.mgz  orig.mgz  rh.ribbon.mgz  subcort.prob.log  T1.mgz

so aparc+aseg.mgz is in there. Maybe your version of sample was outdated?

Copy link
Member

@larsoner larsoner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can anything be refactored with mne.label.find_pos_in_annot?

@alexrockhill
Copy link
Contributor Author

find_pos_in_annot

I didn't see that one, yeah looks like it. I think it might have to be refactored to accept multiple positions though since you wouldn't want to be loading the aseg file over and over.

@alexrockhill
Copy link
Contributor Author

I think it might be best to change the default back to aseg.mgz because fsaverage doesn't have any other segmentations in the sample data.

I just did mne.datasets.sample.data_path(force_update=True, verbose=True) (i.e., not even running fetch_fsaverage) and I see:

$ ls ~/mne_data/MNE-sample-data/subjects/fsaverage/mri
aparc.a2005s+aseg.mgz  aparc+aseg.mgz  brainmask.mgz  lh.ribbon.mgz   orig      p.aseg.mgz     ribbon.mgz        subcort.prob.mgz  transforms
aparc.a2009s+aseg.mgz  aseg.mgz        brain.mgz      mni305.cor.mgz  orig.mgz  rh.ribbon.mgz  subcort.prob.log  T1.mgz

so aparc+aseg.mgz is in there. Maybe your version of sample was outdated?

Yep, mine must have just been way out-of-date.

@alexrockhill
Copy link
Contributor Author

Ok so I changed one thing that I was very unsure about: label.get_pos_in_annot went to label.get_pos_in_aseg which included backdating a function by someone else. Since it was before the next release, I think this might be okay since I think calling it annot is confusing because annot files are something slightly different and already in use to mean a different thing.

Other than that, I tried to refactor to use the function but realized after doing so that it actually would be really inefficient because each channel of the montage is looped over so the aseg would have to be loaded in every time to use that function. I did refactor a bit into a _get_aseg function in _freesurfer.py so that some of the codebase is shared.

If all that is okay, should be good to go.

@larsoner
Copy link
Member

label.get_pos_in_aseg which included backdating a function by someone else. Since it was before the next release, I think this might be okay since I think calling it annot is confusing because annot files are something slightly different and already in use to mean a different thing.

Agreed this naming is better, I'll look at the refactoring now

@larsoner
Copy link
Member

Actually I'll wait until #9544 is merged and this is rebased, feel free to ping me once that's done @alexrockhill

@alexrockhill
Copy link
Contributor Author

I think that looks pretty cool and informative

Screen Shot 2021-07-16 at 1 18 59 PM

@alexrockhill
Copy link
Contributor Author

label.get_pos_in_aseg which included backdating a function by someone else. Since it was before the next release, I think this might be okay since I think calling it annot is confusing because annot files are something slightly different and already in use to mean a different thing.

Agreed this naming is better, I'll look at the refactoring now

I took that part out and put it in a separate PR, this should be good to go as well after I rebase

@larsoner
Copy link
Member

I took that part out and put it in a separate PR, this should be good to go as well after I rebase

The refactoring PR should be merged first, then, right?

@alexrockhill
Copy link
Contributor Author

I took that part out and put it in a separate PR, this should be good to go as well after I rebase

The refactoring PR should be merged first, then, right?

They are actually independent/use the exact same _freesurfer.py _get_aseg code from a git checkout aseg -- mne/_freesurfer.py call.

to show Eric

revert all Brain API changes, for another PR

in progress

pare down

in progress

in progress

in progress

work in progress but conceptually finished

forgot to use the aseg

wip

wip

working version with cool visualization, I think

fix tests

fix gallery number

fix tests

use circular layout

forgot parens

keep channel order, convert to OrderedDict

change default

fix default

wip

refactored label, cleaned up ordering of plot, shared some code

fix doc

fix name error

wip

remove aseg refactoring shared from label

forgot to remove one more refactoring

more fixes
@alexrockhill
Copy link
Contributor Author

Looks good to merge by me!

@larsoner larsoner merged commit b91e4f7 into mne-tools:main Jul 19, 2021
@larsoner
Copy link
Member

Thanks @alexrockhill !

larsoner added a commit to alexrockhill/mne-python that referenced this pull request Jul 19, 2021
* upstream/main:
  [MRG, ENH] Find aseg labels near montage (mne-tools#9545)
  Add label to colorbar in GAT plot [skip actions] (mne-tools#9582)
  [ENH, MRG] Encapsulate warp elec image in function (mne-tools#9544)
  [DOC, MRG] Add "info" to `docdict` (mne-tools#9574)
  [MRG] Add `units` parameter to get_data for Evoked (mne-tools#9578)
  [MRG, ENH] Get annotation description from snirf stim name (mne-tools#9575)
  [MRG] ENH, FIX: Add tmin/tmax parameters to get_data methods, fix bug in find_bads_ecg (mne-tools#9556)
@alexrockhill alexrockhill deleted the aseg branch July 19, 2021 15:35
@drammock
Copy link
Member

@larsoner
Copy link
Member

@alexrockhill can you add a fix to #9540 ? I think that's very close to merge

@alexrockhill
Copy link
Contributor Author

@alexrockhill can you add a fix to #9540 ? I think that's very close to merge

Sure right on it

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

Successfully merging this pull request may close these issues.

4 participants