-
Notifications
You must be signed in to change notification settings - Fork 6
Neonate Scanning (Work In Progress)
Last updated: 20210507
This protocol is heavily based on that from Qiu, L.R., Fernandes, D.J., Szulc-Lerch, K.U. et al. Mouse MRI shows brain areas relatively larger in males emerge before those larger in females. Nat Commun 9, 2615 (2018). https://doi.org/10.1038/s41467-018-04921-2 .
So far, we seek to image pups PND 3-9 (or 10).
- Twenty-four hours prior to the first scan, weigh the dam. Inject her with 0.4 mmol/kg dose of MnCl2, prepared in a bicine buffer administered i.p. Formula and dosage information available in CoBrALab drive (title: MnCl2 Neonate) or upon request to Daniel Gallino and Lani Cupo.
-
Set up the scanner with the correct foam bed from the MRI box, cryocoil, heater, and isoflurane. The pups are too small for the pillow, so it can be left out.
-
Weigh the pup. Induce anaesthesia with 5%, flow rate of ~1.5. Wait ~5 minutes until the pup is anaesthetized. Bring the pup to the scanner. If it is PND3-6 place it as close to the nose cone as possible. If it is PND 7-10, hold it's nose with the nosecone (although not the tooth bar). Tape the pup over it's shoulders, posterior to the brain. Be very careful that for the older pups the chin rest does not strangle them!
-
Acquire the localizer, wobble, reference power gain, and FLASH. Acquire as many localizers as necessary, but with PV6, ensure that the FLASH is always planned to be scan # 2. For PND 3-6 2% isoflurane is sufficient, but for older pups, isoflurane should be maintained at 3% in our current set up to reduce motion.
-
Remove the pup. If it is the first day of scanning, identify the pup with micro-injections in the paws according to your schema. Ensure that you wipe all blood away before returning the pup to its dam. Regardless of day, rub pup with maternal fecal matter before re-introducing it to the dam.
- As with adults, convert the scans with brkraw with instructions found here.
for file in ./2021*; do brkraw tonii -s 2 $file; done
- We next apply a function to rewerite the niftis, which corrects an issue in the Bruker raw data. The function comes from the ANTs package, so we must load this module, if you haven't loaded it already. The output of this step is individual images with _fix.nii.gz appended to their names.
module load ANTs
for file in *nii.gz; do
ConvertImage 3 ${file} $(basename $file .nii.gz)_fix.nii.gz
done
-
QC the structural scans, as you would with adult scans (for a starting place, look here).
-
Convert to mincs for the preprocessing:
for file in ./*fix.nii.gz; do nii2mnc $file $(basename ${file%.nii.gz}.mnc); done
-
make a folder per timepoint: #Here, even if you scanned on P09, call it P10, because I think it needs correspondence with directory names of the models we have from Lily Qiu's work. mkdir p03/ p05/ p07/ p10/
-
move images to corresponding folders in the form:
for file in *03_1-2*.mnc; do mv $file p03; done
-
copy over the model images from the Qiu paper to use in the preprocessing script. They can be found: /data/chamal/projects/lani/neonate/preproc_v3_test/models/Pydpiper-pride-of-models . In the directory where you will house the preprocessing script, you should copy over models/Pydpiper* .
-
Next, run the preprocessing. We use a version of the script that Gabe edited for the neonates from Lani's project, but right now (20230303) it has not yet been centralized the way the other preprocessing scripts have been. This document must be edited when it has been incorporated. a. module load minc-toolkit ANTs b. Copy the preprocessing script to your folder from: /data/chamal/projects/lani/neonate/scripts/neonate_preprocessing_v3_lc.sh c. Make a little script to run the preprocessing:
nano run_neonate_preproc.sh
In this script write:
for dir in .; do
for file in ${dir}/*mnc; do
mkdir -p preproc3_output/$(basename $(dirname $file))
#to run the script, change echo in the next line to bash
echo neonate_preprocessing_v3_lc.sh ${file} $(basename $(dirname $file)) preproc3_output/$(basename $(dirname ${file}))/$(basename $file)
done
done
In this script, dir is each of the directories (p03, p05, etc.). file is each of the mincs. The variable:
Trouble-shooting: if you're running into any errors, first check all of the paths to the models, data, and output and make sure they are what you expect.
- Look at each of the lsq6.mnc images to make sure they are cleaned as expected (for example, not half cropped-out).
You have now finished preprocessing.
The major difference between the adult DBM and the neonatal DBM is that for the neonates we must extract the brains before running the DBM. That is because there is such drastic change from PND 3 to 9/10, especially in the cerebellum, that the registration will fail in these regions, as seen in the top row of the figure below: If we extract the brains, the hard boundary of brain:outside of brain aids registration and allows us to successfully register across timepoints, as seen in the image in the bottom right of the figure above. Here I will explain how to extract the brains.
In order to extract the brains, you need a mask on the individual scans. First, you could check the mask produced by the preprocessing in the steps above, however you may find, as I did, that it is unusably bad, as seen in the image below.
In this case, an efficient way to get a mask on each image is to a) run the DBM on un-extracted brains to get the rough group average, b) make a high-quality, manually corrected mask on the group average c) use the inverse of the transforms from the DBM to transform the mask in average-space to native scan-space. Then, you can manually correct the individual masks, and, since they have a value of "1" where there is brain and "0" where there is not brain, you can multiply the mask and the image to get the extracted image.
-
Run the dbm as you would for adults. The instructions used this dbm, which is now considered old. You can probably take the same approach with the new DBM, however you may have to double check that the file structure and naming conventions did not change. Questions about adapting the process to the new DBM can be directed to Lani Cupo or Gabriel Devenyi (probably more useful). For now, we will precede with the outputs from the old DBM.
-
Check the average. It may look okay! If so, you can also check the transforms from p3 to p5, p5 to p7 etc. For each subject, in the subject* folder, there will be a nifti called extractedWarpedToTemplate* which shows the transformations from the individual timepoints to the average. For each subject, you can image them with a command like:
register *extracted*WarpedToTemplate*
Here you will be able to see whether there are obvious failures. I would honestly be surprised if there are not. -
Make a really good mask on the average that you got from your DBM. For instructions on making a mask, see the wiki here. Instead of the DSURQE, use an age-appropriate model, such as the P7 Ecox mask and average which can be found here: /opt/quarantine/resources/P7_ECox_2015/ex-vivo/
-
Once you have a very good mask on the average, you can propagate the mask to the individual scans. This should be done on Niagara, in the folder you ran your DBM.
Create a propagate_mask.sh script with the following: module load cobralab/2019b
for file in inputs/*.nii.gz; do
subj_to_scan_affine=output/subject*/*$(basename ${file} .nii.gz)*0GenericAffine.mat
echo $subj_to_scan_affine
subj_to_scan_nlin=output/subject*/*$(basename ${file} .nii.gz)*1InverseWarp.nii.gz
echo $subj_to_scan_nlin
template_to_subject_affine=output/secondlevel/*$(basename $(dirname $subj_to_scan_affine))_template*0GenericAffine.mat
echo $template_to_subject_affine
template_to_subject_nlin=output/secondlevel/*$(basename $(dirname $subj_to_scan_nlin))_template*1InverseWarp.nii.gz
echo $template_to_subject_nlin
antsApplyTransforms -d 3 -i manual_mask.nii.gz -t [ $subj_to_scan_affine ,1 ] -t $subj_to_scan_nlin \
-t [ $template_to_subject_affine ,1 ] -t $template_to_subject_nlin \
-o propagated_masks/$(basename ${file} .nii.gz)_mask.nii.gz -r $file --verbose -n GenericLabel
done
This script takes as inputs: 1. the inputs file from your DBM with all of the niftis in it (from this it derives the subject number and finds the appropriate transformations associated with each individual scan) 2. a manual_mask in nifti format which is your mask on the template average. It outputs a scan-appropriate mask in a folder called propagated_masks.
-
After the script has run succesfully, on the CIC, visualize each input image-mask pair. This can be done with a loop such as:
for file in inputs/*.nii.gz; do Display -gray $file -label $(basename $file .nii.gz)_mask.nii.gz; done
Make note of bad masks. -
If you need to correct any masks (which you probably will, because the images that registered improperly in the DBM will have badly-propagated masks), then do this now. First convert them to mincs, since you can only edit and save labels in minc format properly. Then, edit the masks, as directed for embryos in this wiki.
-
Once you have a good mask on each image, gather them together in a single folder. This should include one mask per image, either the output from the mask propagation, or the manually-edited version. Convert all mincs back to niftis.
-
Multiply the input images times the masks to get the extracted brains as the output. This example command is run in a folder containing all of the masks named something like subject_number_mask.nii.gz. In the ImageMath command (part of ANTs), the format is: ImageDimension <OutputImage.ext> [operations and inputs] <Image1.ext> <Image2.ext>, so here we have a 3 dimensional image, the output will be called subject_number_extracted.nii.gz, we are "m" multiplying the inputs, the first input is the input image as a nifti stored in ../inputs/, and the second input is the mask, in the current directory (file). `For file in .nii.gz; do ImageMath 3 ${file%_mask}_extracted.nii.gz m ../inputs/${file%_mask*}.nii.gz $file; done
-
Display each of the resulting images to make sure they look good.
-
Now you can re-run your dbm using the extracted brains as inputs. IMPORTANT: you should use an extracted target for the DBM. You can either use the extracted average from your previous DBM run, or you can use one of mine, such as neonate_average_extracted.nii.gz which I cheekily put in a folder called: /data/chamal/projects/lani/neonate/Cupo_Devenyi_Gallino_atlas (it's not really an atlas).
-
After your DBM, be sure to check the individual files again to make sure that the new approach did the trick.