Skip to content

NF1 LabelMap Generation Project

KKnoernschild edited this page Jun 28, 2019 · 1 revision

Documentation for MINIPIG brain Labelmap Generation

Current projects completed on CAUDATE;

Source code browsing for SLICER and how it stores and processes files using Python

Created Sphinx Documentation for CreateSegmentationFile - takes in a labelmap and then uses Slicers Segmentation Editor to create a new .nrrd.seg image

CreateSegmentationEditor uses python combined with nodes in SLICER to automatically generate a segmentation for an inputted labelmap. Generally took good notes on the SLICER wiki pages. Use those as references as well

MINIPIG BRAIN PROJECT

RESULTS LOCATED IN DIRECTORY : /Shared/johnsonhj/2018Projects/20180514_MiniPig_BIDS/fcsv_Im_Pairs

Inspected 35 subjects totaling 118 (double checked source data and counted) individual scans ( some subjects had multiple sessions, some only had 1) Used Slicer to create fcsv files that contain the following markups of the brain BPons MPJ mid_prim_sup/inf r/l_lat_ext r/l_front_pole r/l_sup_ext Rostrum Genu r/l_ventricle r/l_caud_head

The same process was then repeated for the initial ATLAS images, in creating the original fcsv files This each of the 5 atlas images all have an image, corresponding atlas labelmap, and corresponding landmarks saved as a fcsv

The atlas images,fcsvs,and label-maps are then fed into a pipeline where they are transformed into the same image space as the current subject that is being processed. 0.These 5 transforms are then applied and reregistered to create a new labelmap using antsJointFusion. The output of this joint fusion is a completed labelmap where all 5 of the labelmaps have been transformed to the new image space, using nearest neighbor for pixel approximation, while using the brain images of the ATLASES and the image that the transfer is happening to, looking at the general pixel intensity/density of the mri

The resulting labelmaps were then checked after this initial run with the labelmap being ovelayed over the subject brain. A csv file containing 18 of these subjects of the initial run were then selected due to having good fit with the image. These 18 generated labelmaps were then reapplied IN ADDITION TO THE ATLAS LABELMAPS to attempt to further hone in the labelmap generation in simulated Bootstrapping

Due to there not being an incredible match for most of the labelmaps after the second run, I went back and checked the fcsv files and moved around all points on the cerebrum, because there was a tendency for the transforms to shrink to just inside where the actual cerebrum location was. When reviewing the markups there was a tendency for those locations to be just inside where they should have initially been placed.

Steps 4 and 5 were then repeated with the more accurate fcsv files, there was noticeably better results for the edge of the cerebrum when antsJointFusion finished.

Still had brain images where there were large leaks outside where the brain was putamen / ventricle / label placement for the inside of the brain is accurate Most error comes from the cerebrum label result or around the brain stem Next steps taken are to try and accurately give a placeholder that isnt a brain marker, but is relative to easily found markers (i.e. AC +- 3x the difference between AC and PC on the same plane) The issue with the way current landmarks are set up, is that most of the landmarks tend to fall on 1 of 2 planes, and that is mirrored on each side, so any variation off those planes in the transform causes there to be a huge effect on the following transform that occurs in antsJointFusion These different points added to the fcsv files do not seem to make the results better Edge of the brain is expanding outwards way further than it should The anchor points dont seem to be working as they would be intended to

Masked images are created from the transformed image space, but the original image does not get masked, just a combination of those input masks

Maybe if there was a way to pre mask out the brain itself and then just use that as the final output mask after the ants fusion

That would get rid of the leaking - i have a feeling that the masks being applied juts allow for too much wiggle room

The final solution for the time being is to go through the 2nd generation of images (generated from the best labelmaps and the original atlases) and hand edit the edges where the labelmap of the brain is overrunning into the skull/surrounding area.

For future reference, you need to use slicer to edit the labelmaps. Drag/load the T1Image and the labelmap, and then right click the labelmap under the "Data" tab. Click create segmentation in that drop down menu, and then go to the "segmentation editor" in the dropdown tool. You can go slice by slice, or you can use the 3d view and click either paint/erase depending on what you want to do, as well as the 3d sphere fill option. This will help you cover more area and not have to go slice by slice. You can increase the size of the sphere/circle using shift and the scroll wheel. Left click to paint/erase based off what you are wanting to do

118 labelmaps are located in /Shared/johnsonhj/2018Projects/20180514_MiniPig_BIDS/Final_Labelmaps.

Rerun directory is just for dragging individual cases when calling the main functions.

Naming structure as follows {subject}_{session_date_run}_T1w_label.nii

example) sub-Katharina160_ses-20130328_run-094446_T1w_label.nii

FileStructure - /Shared/johnsonhj/2018Projects/20180514_MiniPig_BIDS contains all the resultant files, as well as the original data. Derivatives and sourcedata are the original data that was provided, and the T1w images were transferred to the directory location fcsv_Im_Pairs, to avoid messing with original data.

Final_Labelmaps contains the resultant labelmaps for all T1w images. Fcsv_Im_Pairs contains T1 image , Fcsv file containing labels, as well as the final labelmap that was generated from 2 rounds of joint fusion (first round using origninal atlas images, second round using original atlas images, and 12 best fitting subject labelmaps from the first round)

/Shared/johnsonhj/2018Projects/20180514_MiniPig_BIDS/testscriptAtlas is where everything code related or csv related is located. Csv files provided in this folder are specifically for the locations of the input images/atlas labels depending on if its first or second run with the original 5 or combined 18 labelmap references.

  • AtlasLabel_t1_pair.csv is the original 5 atlas list
  • atlasinputs.csv is the combined list

Code/useful files links to SINAPSE backups:

CreateLabelMap

ReApply (secondary run with 17 reference images/masks)

MaskImage.py

ExtractBrain.py

Extract brain is used to make sure the only input image data is from the brain region, and MaskImage is used to create a binary mask of the extracted region. This is used in the antsJointFusion as an input mask in the image space that is needed.

WikiPageLinks:

Minipig_LabelMap_Generation

Segmentation Automation Ideas

SLICER_Segmentation_Src_research

Segmentation Links (automation may be useful)