Articles on alexrockhill's Bloghttps://blogs.python-gsoc.orgUpdates on different articles published on alexrockhill's BlogenThu, 19 Aug 2021 18:08:01 +0000Final Reporthttps://blogs.python-gsoc.org/en/alexrockhills-blog/final-report-1/My GSoC project to make a graphical user interface (GUI) to locate the positions of electrical recording contacts inside a patient's head who has been implanted with intracranial electrodes was a huge success. I started by developing the accompanying routines to prepare the input data and process the data once the GUI has been used first. This process is described here: https://mne.tools/dev/auto_tutorials/clinical/10_ieeg_localize.html The pull requests (PRs) that contributed to this development are here: https://github.com/mne-tools/mne-python/pull/9484 https://github.com/mne-tools/mne-python/pull/9544 https://github.com/mne-tools/mne-python/pull/9601 These were also accompanied by maintenance PRs to the MNE-Python repository as a whole which improved its overall organization and function and were part and parcel with the tutorial changes: https://github.com/mne-tools/mne-python/pull/9480 https://github.com/mne-tools/mne-python/pull/9543 https://github.com/mne-tools/mne-python/pull/9574 https://github.com/mne-tools/mne-python/pull/9598 https://github.com/mne-tools/mne-python/pull/9599 https://github.com/mne-tools/mne-python/pull/9601 https://github.com/mne-tools/mne-python/pull/9617 https://github.com/mne-tools/mne-python/pull/9618 https://github.com/mne-tools/mne-python/pull/9622 https://github.com/mne-tools/mne-python/pull/9625 https://github.com/mne-tools/mne-python/pull/9630 In brief, this allowed users who had collected intracranial electrophysiology data to take a computed tomography (CT) scan with electrode contacts appearing as hyperintensities, align it to a magnetic resonance (MR) image and then compute a morph mapping from the patient's brain to a template brain (a brain made of the average of many different MR scans so as to be somewhat representative of an average brain). The many helper PRs reorganized image processing scripts, fixed naming consistency, removed redundancy in documentation and refactored many of the 3D plotting aspects that were used in the tutorials. Once the accompanying routines were completed, the GUI PR was the main focus: https://github.com/mne-tools/mne-python/pull/9586 The main GUI implements a novel automatic contact finding algorithm, specifically developed for identifying many stereo-electrodes in lines (previous algorithms have been developed for grid electrodes) and is a clean and well-tested interface for locating intracranial contacts that is up to professional development standards.aprockhill206@gmail.com (alexrockhill)Thu, 19 Aug 2021 18:08:01 +0000https://blogs.python-gsoc.org/en/alexrockhills-blog/final-report-1/Week 10: Wrapping uphttps://blogs.python-gsoc.org/en/alexrockhills-blog/week-10-wrapping-up/The graphical user interface for selecting intracranial electrode contacts is finally feature complete! I just have a few tests to write and to get it reviewed but we're nearing the end of a successful GSoC project.aprockhill206@gmail.com (alexrockhill)Sun, 15 Aug 2021 21:04:57 +0000https://blogs.python-gsoc.org/en/alexrockhills-blog/week-10-wrapping-up/Week 9: Finishing up the GUIhttps://blogs.python-gsoc.org/en/alexrockhills-blog/week-9-finishing-up-the-gui/I'm working on the 3D viewer as a fourth panel of the GUI and progress is going well, but I still have to add tests. Next up is the last step of automating the detection of the electrode contacts so that locating positions is automated and the user only has to associate the positions.aprockhill206@gmail.com (alexrockhill)Thu, 05 Aug 2021 17:36:07 +0000https://blogs.python-gsoc.org/en/alexrockhills-blog/week-9-finishing-up-the-gui/Week 8: Progress on Coordinate Frameshttps://blogs.python-gsoc.org/en/alexrockhills-blog/week-8-progress-on-coordinate-frames/This week, I managed a lot of the input/output for the GUI which was complicated and was nicely clean up in the refactoring in the rest of MNE. This was also a part of the 3D plotting that will be useful to displaying the results of the GUI. Next week is on to adding functionality and tests for the GUI, specifically the 3D view.aprockhill206@gmail.com (alexrockhill)Thu, 05 Aug 2021 17:34:09 +0000https://blogs.python-gsoc.org/en/alexrockhills-blog/week-8-progress-on-coordinate-frames/Week 7: Progress on the GUIhttps://blogs.python-gsoc.org/en/alexrockhills-blog/week-7-progress-on-the-gui/The electrode contact localization GUI is in progress and a first draft that incorporates MNE style and helper functions is almost finished. I worked on handling the coordinate frames in a easy-to-understand way, and I worked on refactoring and renaming the appropriate functions and variables to be private as well as simplifying a bit like not plotting the pial surface to add back later. This week I'll finish the draft, get and incorporate reviews and work on tests. Hopefully soon it will be integrated into the tutorial with helpful images.aprockhill206@gmail.com (alexrockhill)Mon, 26 Jul 2021 06:11:14 +0000https://blogs.python-gsoc.org/en/alexrockhills-blog/week-7-progress-on-the-gui/Week 6: A start on the main GUI and lots of helper PRshttps://blogs.python-gsoc.org/en/alexrockhills-blog/week-6-a-start-on-the-main-gui-and-lots-of-helper-prs/This week I worked on adding volume labels based on a Freesurfer anatomical segmentation file and plotting those files with an mne.viz.Brain object which operates in Freesurfer surface space and has lots of flexibility for 3D plotting. Next, it's developing the core GUI as much as possible until the end of GSoC and making it smooth and well tested. I'm not stuck on anything and it's been a good week for getting some PRs merged.aprockhill206@gmail.com (alexrockhill)Mon, 19 Jul 2021 14:31:03 +0000https://blogs.python-gsoc.org/en/alexrockhills-blog/week-6-a-start-on-the-main-gui-and-lots-of-helper-prs/Week 5: Merging PR, Progresshttps://blogs.python-gsoc.org/en/alexrockhills-blog/week-5-merging-pr-progress/This week, I made a lot of progress on setting up for the GUI. A PR is approved that refactors the freesurfer functions that are necessary for the GUI. Also, more thought and effort went into the data a typical user would have, their workflow and the coordinate frames that the image processing will function in. This has culminated in two more PRs in progress for refactoring the electrode volume morphing, which contains many functions that will be reused in the pipeline, and adding anatomical segmentations from a montage which uses those functions. Those anatomical segmentations will be used to provide functionality that takes a label, uses marching cubes to determine surfaces and displays the 3D surfaces along with the electrode contacts. Those PRs will be in the coming weeks. Halfway though, much progress has been made and I'm happy with where the project is at and confident that a good product can be delivered on time.aprockhill206@gmail.com (alexrockhill)Mon, 12 Jul 2021 05:58:00 +0000https://blogs.python-gsoc.org/en/alexrockhills-blog/week-5-merging-pr-progress/Week 4: More Debugging and Catching uphttps://blogs.python-gsoc.org/en/alexrockhills-blog/week-4-more-debugging-and-catching-up/This week I started porting over the GUI and figuring out the integration questions like how to set the rendering backend as well as laying the groundwork (raising an issue and discussing) smaller PRs which will help such as adding subcortical freesurfer recon-all structures to plotting which will need to happen to visualize everything nicely. Things are moving along and the (almost) merged PR that sorts out the registration and diffeomorphic warping is done (except for a few housekeeping items). That was very complicated to integrate into existing code but, in the end, I'm very happy that the tests all passed and this implementation is functionally equivalent to the previous but also gives accurate MR-CT alignments that the last one did not. The API is simpler, and there was a bit of a workaround that after each step the registration was applied instead of being used as a seed for the next step as the API of Dipy suggests is the best case. In fact, there was trouble with this seeding method and the apply method gave great results and was consistent in forward and back tests. Next week, I'll really concentrate on the GUI and hope to get everything working and lightning quick so that I can get feedback on the layout and usability and go from there.aprockhill206@gmail.com (alexrockhill)Sun, 04 Jul 2021 18:21:58 +0000https://blogs.python-gsoc.org/en/alexrockhills-blog/week-4-more-debugging-and-catching-up/Week 3: A Bit of A Delay but Maybe Quicker in the Endhttps://blogs.python-gsoc.org/en/alexrockhills-blog/week-3-a-bit-of-a-delay-but-maybe-quicker-in-the-end/This week I was scheduled to be working on the VTK implementation of the graphical user interface but instead finished and polished (or are nearly done polishing with a lot of Eric's help) the affine registration and symmetric diffeomorphic registration steps to be done efficiently and reuse existing morphing code. This lays the groundwork for later developments, such as weeks 5 and 6 when the contact identification algorithms will be improved because we used a 3D image to do the SDR morph and had to label all the voxels that the contacts occupied from their centroid location. This is an essential step in the automating of contact identification and will be important as I both port over the GUI and add an automated identification algorithm.aprockhill206@gmail.com (alexrockhill)Sat, 26 Jun 2021 03:23:04 +0000https://blogs.python-gsoc.org/en/alexrockhills-blog/week-3-a-bit-of-a-delay-but-maybe-quicker-in-the-end/Week 2: Getting into the Implementationhttps://blogs.python-gsoc.org/en/alexrockhills-blog/week-2-getting-into-the-implementation/This week I worked on translating existing code to register a CT to an MRI and warp one MRI to an average template into a mne-python example. The existing code works great, but there are quite a few dependencies so I looked into refactoring and reimplementing. That hasn't gone smoothly yet but I think I have learned quite a bit about all the algorithm implementations so that I know what needs to be done. I was able to eliminate a skimage dependency by refactoring to use the marching cubes implementation in VTK so that was the first success. I might have to add back the skimage dependency if I reimplement the histogram registration though. I am a bit stuck on getting the example to execute quickly and making it easy to understand for the user as multiple dependencies and their formats make that tough. I'm waiting for reviews to help out with that as I move on to improving the implementation of the GUI by embedding VTK plots instead of matplotlib.aprockhill206@gmail.com (alexrockhill)Sat, 19 Jun 2021 17:02:57 +0000https://blogs.python-gsoc.org/en/alexrockhills-blog/week-2-getting-into-the-implementation/Week 1: Setting Uphttps://blogs.python-gsoc.org/en/alexrockhills-blog/week-1-setting-up/This week I started a new repository, `mne-ieeg-localize` for the project! I set up tests and documentation and ported over one function from previous work and mostly raised it to MNE standards. I'm a bit stuck on test writing and testing data. For now, I think I will host the test data on Google Drive and figure out how large the file size needs to be. It will be in the neighborhood of 2 - 4 GB and the 3D image processing makes the test take on the order of tens of minutes or hours. I need to find a way to work around these issues to make sure that the tests still cover functionality while not being prohibitively long. This week I plan to finish the implementation of the coregistration and compare the Dipy affine alignment to the Nipy histogram registration. Ideally, we could remove this dependency by writing it all in numpy, but the symmetric diffeomorphic registration would be a big ask to reimplement and so Dipy is a dependency that looks to be here to stay. It's worth looking into if it's not too much to write these functions to be maintained as part of the package. I was a bit busy this week as I had my comprehensive/prelim PhD candidacy exams so Iaprockhill206@gmail.com (alexrockhill)Mon, 14 Jun 2021 01:59:46 +0000https://blogs.python-gsoc.org/en/alexrockhills-blog/week-1-setting-up/Getting Startedhttps://blogs.python-gsoc.org/en/alexrockhills-blog/getting-started/I'm excited for the ieeg localization project and ready to hit the ground running. I have been working on changing the dependency on the freesurfer mri_cvs_register function that takes 15+ hours to do a combined surface and volume registration to depend on a symmetric diffeomorphic registration implemented in Dipy. Up next, I will migrate the project into mne-tools and set up basic tests and documentation. Fortunately, I'm not stuck on anything!aprockhill206@gmail.com (alexrockhill)Mon, 07 Jun 2021 18:30:58 +0000https://blogs.python-gsoc.org/en/alexrockhills-blog/getting-started/