Skip to content

MRG+1: head_to_mni - #4344

Merged
larsoner merged 68 commits into
mne-tools:masterfrom
annapasca:aseg2MNI
Apr 12, 2018
Merged

larsoner merged 68 commits into
mne-tools:masterfrom
annapasca:aseg2MNI

Conversation

@annapasca

Copy link
Copy Markdown
Contributor

fixed bug in color of aseg label

- color = np.array(all_labels_aseg[1][ind]) / 255
+ color = tuple(np.array(all_labels_aseg[1][ind]) / 255.)

add function to convert to MNI space the coo of aseg labels

@codecov

codecov Bot commented Apr 4, 2018 •

Copy link
Copy Markdown

Codecov Report

Merging #4344 into master will increase coverage by 0.1%.
The diff coverage is 100%.

@@            Coverage Diff            @@
##           master    #4344     +/-   ##
=========================================
+ Coverage   87.97%   88.07%   +0.1%     
=========================================
  Files         356      356             
  Lines       64997    65322    +325     
  Branches    11101    11128     +27     
=========================================
+ Hits        57181    57533    +352     
+ Misses       4982     4960     -22     
+ Partials     2834     2829      -5

@annapasca

Copy link
Copy Markdown
Contributor Author

Hi @agramfort !
I made some little changes and added test_aseg_vertex_to_mni but I don't know if this test makes sense.

About the travis error, it seems to me that the only error is that I have to add aseg_vertex_to_mni in doc/python_reference.rst. Is it? and if yes where?

Thks!

@larsoner

larsoner commented Apr 6, 2018

Copy link
Copy Markdown
Member

In the "Source Space Data" section, you can put it in as source_space.aseg_vertex_to_mni

@larsoner

larsoner commented Apr 6, 2018

Copy link
Copy Markdown
Member

Actually it's in mne/__init__.py so you can put it in "Source Space Data" as just aseg_vertex_to_mni

@larsoner larsoner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Other than a few minor comments, LGTM

Comment thread mne/source_space.py Outdated

Parameters
----------
vertices : n_vertices x 3 array of float

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If these are in the head coordinate system, pos would be a better name. vertices we try to reserve for vertices on a FreeSurfer mesh.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done!
Since aseg_vertex_to_mni works also for vertices in the cortex surface, do we have to change
the name?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Well it doesn't work for "vertices" in the sense that we typically mean "vertices" in mne. "vertices" in MNE refer to indices into a subject's Freesurfer surface mesh, not (n, 3) arrays of the coordinates of those points.

This function as far as I can tell will take any point in head coords and convert it to MNI coords. So the name is a bit odd. Maybe it should be head_to_mni? @agramfort WDYT?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I changed in the function vertices with pos.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes inside the function the name has changed. I'm talking about the name of the function itself aseg_vertex_to_mni actually does something different, it converts (any) points in the head coordinate frame to the MNI coordinate frame, right?

@annapasca annapasca Apr 6, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, also to me now aseg_vertex_to_mni is a weird name.
head_to_mni sounds good.

Comment thread mne/source_space.py Outdated
subjects_dir = get_subjects_dir(subjects_dir, raise_error=True)

# before we go from head to MRI (surface RAS)
head_mri_t = invert_transform(mri_head_t)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

head_mri_t = _ensure_trans(mri_head_t, 'head', 'mri')

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread mne/source_space.py Outdated
try:
ind = all_labels_aseg[0].index(roi_str)
color = np.array(all_labels_aseg[1][ind]) / 255
color = tuple(np.array(all_labels_aseg[1][ind]) / 255.)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why tuple this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I did this change a lot of months ago so now I don't remember the reason...
Can I leave tuple?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It would be better to revert if possible, we try to keep ndarray unless there is a reason not to

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok, I reverted it!
If I remember the reason I'll update you.

Comment thread mne/source_space.py Outdated
The coordinates (in m) of the vertices in head coo system
subject : string
Name of the subject to load surfaces from.
mri_head_t: Transform

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can just call this trans, we do this in user-facing functions

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread mne/source_space.py Outdated
subject : string
Name of the subject to load surfaces from.
mri_head_t: Transform
mri head tranformation

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

MRI<->Head coordinate transformation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread mne/source_space.py Outdated
"""
if not has_freesurfer() and not has_nibabel():
raise RuntimeError('NiBabel (Python) or Freesurfer (Unix) must be '
'correctly installed and accessible from Python')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's let _read_talxfm handle throwing errors. If what is there is not already sufficient, let's improve it there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok

Comment thread mne/source_space.py Outdated
Parameters
----------
vertices : n_vertices x 3 array of float
The coordinates (in m) of the vertices in head coo system

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

head coordinate system.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@larsoner larsoner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Other than a minor gripe, LGTM.

@agramfort feel free to merge if you're happy after my small comment is addressed

Comment thread mne/source_estimate.py Outdated
return_several = False
return_generator = False
elif isinstance(stcs, MixedSourceEstimate):
stcs = [stcs]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think this should be part of this PR? (Also I think you want return_several = return_generator = False for this when it is eventually part of a PR.)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1

@larsoner larsoner added this to the 0.16 milestone Apr 8, 2018
Comment thread mne/source_estimate.py Outdated
return_several = False
return_generator = False
elif isinstance(stcs, MixedSourceEstimate):
stcs = [stcs]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1

Comment thread mne/source_space.py Outdated

Parameters
----------
pos : n_pos x 3 array of float

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

bad formatting. It should be:

pos : array, shape (n_pos, 3)

Comment thread mne/source_space.py Outdated

Returns
-------
coordinates : n_pos x 3 array of float

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

coordinates : array, shape (n_pos, 3)

Comment thread mne/source_space.py Outdated
The coordinates (in m) in head coordinate system
subject : string
Name of the subject.
mri_head_t: trans

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

trans -> instance of Transform

@larsoner larsoner changed the title Aseg2 mni MRG+1: Aseg2 mni Apr 9, 2018
@larsoner larsoner changed the title MRG+1: Aseg2 mni MRG+1: head_to_mni Apr 9, 2018
@agramfort

Copy link
Copy Markdown
Member

you have travis errors due to bad docstring formatting.

@larsoner

Copy link
Copy Markdown
Member

Thanks @annapasca !

@larsoner
larsoner merged commit 12de055 into mne-tools:master Apr 12, 2018
@larsoner larsoner mentioned this pull request Apr 13, 2018
26 of 29 tasks
britta-wstnr pushed a commit to britta-wstnr/mne-python that referenced this pull request Jul 5, 2018
* new functions to hangle mixed src spaces in inverse

* example script

* add get_volume_labels_from_src
delete extract_label_time_course_AP

* compute connectivity btw 74 regions in a mixed src space

* delete extract_label_time_course_AP, _gen_extract_label_time_course_AP
and overwrite extract_label_time_course, _gen_extract_label_time_course

* add get_volume_labels_from_src

* minor fix

* minor fix

* minor fix

* get_volume_labels_from_aseg_AP removed

* added test_read_volume_from_src

* _get_lut_AP removed
volume_label could be a list
get_volume_labels_from_aseg_AP removed

* minor fix

* only compute the inverse in mixed source space

* connectivity on mixed src space

* minor fix

* minor fix

* minor fix

* minor fix

* new test_source_space_from_label

* minor fix

* docstyle update

* minor fix

* change pos value

* minor fix

* change comment

* minor fix

* minor fix

* add return_colors par to get_volume_labels_from_aseg

* minor fix

* minor fix

* minor fix

* minor fix

* minor fix

* minor fix

* minor change

* minor change

* add plot of some labels

* add check on FO and pick_ori to set psd dim

* minor fix

* add test for compute_source_psd()

* minor change

* unified test for compute_source_psd

* add check MixedSourceestimate

* added aseg_vertex_to_mni

* fix bug color aseg

* delete white spaces

* remove xfm as output, add mri_head_t as input

* update inputs

* added test_aseg_vertex_to_mni

* added aseg_vertex_to_mni

* changed vertices -> pos

* aseg_vertex_to_mni -> head_to_mni

* removed check in  extract_label_time_course

* minor fix

* minor fix

* removed blank line
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.

3 participants