Skip to content

Minipig_LabelMap_Generation (edited formatted better)

KKnoernschild edited this page Jun 20, 2019 · 26 revisions

Minipig Brain Project

Goal

  • using atlas images, and images from MINIPIG_BIDS, generate labelmaps using BRAINSLandmarkInitializer and antsJointFusion

Steps

  1. Inspect subject minipig scans, and mark off which ones that have extremely blurry or orientation problems (only 1-2 subjects)
  2. Individually mark the following brain locations on every minipig scan. These markups were saved to .fcsv files that were labelled the same name as the minipig scan file, with _markup.fcsv added to the file ending in place of the .nii.gz
    • BPons
    • MPJ
    • VN4
    • mid_prim_sup
    • mid_prim_inf
    • r/l_lat_ext
    • r/l_front_pole
    • r/l_sup_ext
    • Rostrum
    • Genu
    • l/r_ventricle (in most cases)
    • l/r_caud_head
    • AC
    • PC
    • 4x distance (AC-PC) in front of the PC (same plane, adjusted if the brain was not centered)
    • 3x ditance (AC_PC) to both the left and the right of the PC (same plane, adjusted if the brain was not centered)
  3. Repeated this markup process for the 5 ATLAS brain scans provided.
  4. Wrote small test scripts to get used to how BRAINSLandmarkInitializer and antsJointFusion worked.
  5. Began larger process of applying multiple masks and transforms to BRAINSLandmarkInitializer, BRAINSResample , and antsJointFusion

Script Steps / Logic

  1. To call the script, type bash testscript.sh /Shared/johnsonhj/2018Projects/20180514_MiniPig_BIDS/testscriptAtlas/AtlasLabel_t1_pair.csv /Shared/johnsonhj/2018Projects/20180514_MiniPig_BIDS/fcsv_Im_Pairs
    • AtlasLabel_t1_pair.csv is a csv file that contains all the atlas images, and their corresponding label maps and fcsv markup files
    • you will also need a weight file that is provided in the folder of the script, as well as the python script MaskImage.py , which is used to mask resulting transforms that are applied to the ATLAS images, to exclude all non-brain pixels when being applied to antsJointFusion
  2. Find all the pairs of images and their matching fcsv files. Currently since there is an fcsv file for every subject, and they all follow the same naming convention, you can put these into an array in bash , and just call them to be ran in a loop per subject (probably should be changed to check to make sure these numbers match)

enter loop and start processing / transforming images (for each atlas the following happens)

  1. Since the goal is to transform all the atlas images to the new image space of the subject, we need to run the BRAINSLandmarkInitializer code.

    1. Before we apply the transform, we use the labelmap and the the original ATLAS image, to create an image that masks out all values but the brain. This way the brain is the only thing that has pixel values after the transform to the new image space occurs.

      • all cropped images are labeled as atlas${i}_Label_2_${subj_study}_${TFMTYPE2}_skull_cropped.nii , where i is the atlas number , subj_study is the current atlas subjects study file name, and tfmtype2 is the transform that will later be applied CHECK THIS THIS MAY BE THE ISSUE TFMTYPE2 BEING CALLED BEFORE INSTANTIATION
    2. Run The BRAINSLandmarkInitializer. transform file is written as .h5

      • $(pwd)/${subj_study}/TransformFiles/testatlas${i}_2_${subj_study}_${TFMTYPE}_${INTERPMODE}.h5 , where i is the atlas number, subj_study is the subject study (date/name/ect) , TFMTYPE is the transform type (will always be Affine in this case) , and INTERPMODE is the interpolation (Linear)
    3. This .h5 is then used by BRAINSResample to transform the image into the same image space that the MINIPIG subject is located

      • the transformed image is then saved as$(pwd)/${subj_study}/ImageFilesLinear/atlas${i}_${INTERPMODE}2${subj_study}.nii
    4. We then repeat the same process for the atlas labelmap images, since those are still going to be in the same image space as the original untransformed image.

      • the only difference is that NearestNeighbor is used as the Interpolation mode, so that there is no extra label numbers applied to the original (ie averages / haloing due to other interpolation methods) , and just a transform is applied
    5. Now we use the transformed ATLAS images and label maps with antsJointFusion. For this process We insert all the atlas images , labelmaps ,and the masks that were created from the transformed images, to get an output of those 5 atlases applied to the image space of the minipig brain *search radius of 3 , 5 , 9 were used in testing, and there was no significant change besides spilling outside of the brain area.

  2. Resulatant label masks were then observed, and the top matching label maps were chosed to be added to the registration pseaudo-ATLAS list. This list of ~18 ATLAS images was then reapplied through the same exact process, but with the additional new ATLASES fed into the system.

Other Steps taken and problems.

* Main issue is the labelmap thats resultant spilling out of the brain image, or not expanding to the outer part of the cerebrum enough

first round subject Ada2013 , poor labelmap generation from antsJointFusion

test

second round subject Ada2013

Bad_second_run

Better Fitting Labelmap example (still some filling errors)

OutputIm

Better Fitting round 2 (you can see some filling areas on the frontal portion of the cerebrum, as well as the brain stem / BPONS area)

JulianaRound2

Results and File Structure

  • currently all results are located in the 20180514_MiniPig_BIDS folder

TestScriptAtlas - location of scripts and the overhead folder location where all results will be located