There is light…

Hey everyone!

The journey is almost over as this is probably one of my last, if not the last blog post related to this project.

I will try to summarize what the project’s current state is. Further I would like to shortly sum up what I think where my personal benefits from this project (idealistic benefits 😉 ).

But first let’s get into the code.

Download the necessary data for example 7 from GitHub. Replace the respective files in your mne root directory and run:

python install to apply the changes and register the new class.

If you wish, you could navigate to mne-python/doc and run:

PATTERN=<pattern> make html_dev-pattern

Possible options (at least what concerns my work) are:

, which are 3 tutorials and 2 examples (that order). Beside adjusting previous API for the use with SourceMorph, the class itself was created including the respective testing files.

Now let’s see what that’s all about:

This is a tutorial explaining the basic concept of using FreeSurfer as tool for anatomical segmentation and reconstruction of MRI images. It gives an overview of which parts of FreeSurfer are relevant for MNE-Python users and relates the FreeSurfer logic to MNE.

In this tutorial it is explained what stc is, namely a source estimate class representing surface source estimates. First it is explained of which parts a source analysis in MNE-Python consists and hands-on explained what the actual Python object means.

Thereby it is taken care of, that the user understands the basic relationship between 3D coordinates of an anatomical brain representation and time series at those locations.

Here the class SourceMorph is introduced and shortly explained what it does and how to use it.

A small introduction about the usefulness of morphing, is followed by by an explanation for both – surface and volume – types of surce estimates. Details about the common and diverging functionality are pointed out. Reading and saving is explained and possible API shortcuts are mentioned.

Within this example, it is shown how a surface source estimate is morphed in MNE-Python. Example data is used and the result shown as a plot depicting the morphed source estimate on a FreeSurfer surface representation.

Basically the same example as above only focusing on volume source estimates, rather than surfaces.

Here the actual class – SourceMorph – is implemented. The file carries several private helper functions as well as the exposed public API for morph related functions.

A SourceMorph is initialized by calling as a core class of MNE including the respective parameters.

morph = mne.SourceMorph(src=src)

An actual source estimate can then be morphed by calling the newly created instance.

stc_morphed = morph(stc)

In case of a volume source estimate, the morphed data can also be converted into a NIftI image.

img = morph.as_volume(stc_morphed)

I will not go into detail in all the small modifications and separate functions, but feel free to explore them (and report any bugs 😉 )

So what have I learned?

Well turns out the main experience that I will surely carry over to my own work – and did so already – concerns styling issues and communication in professional software development. I would like to phrase it in a nutshell as:

Think before you push!

Furthermore – also related to more professional development – I found a way to finally organize everything locally in a more or less clean way, such that no data gets lost but still version Zombies like “” are avoided effectively.

I guess I just did learn what was expected, namely to “build better software”

In that sense I hope you enjoyed the journey as much as I did!

See you next year 😉



PS: depending on how the final two week go with handing in results etc, I might even post a last one, referring to the actually merged files…