Index
Contents
For questions/feedback, please contact Meena M. Makary, Ph.D. (mmakary@mgh.harvard.edu) and Dr. Ciprian Catana (ccatana@mgh.harvard.edu) OR use this Teams Channel Positron
Integrated PET-MR Imaging Lab (Catana Lab), Athinoula A. Martinos Center for Biomedical Imaging
Brain PET Data Reconstruction
Usage Note
This section is only to process PET-MR data acquired using BrainPET (Bay 6) scanner at the Athinoula A. Martinos Center for Biomedical Imaging.
This version mirrors the attenuation map generation and reconstruction algorithms that were used on Aether. We recommend using this version only for continuation studies. Scripts are located inside: /autofs/cluster/petcore/PET_computer_backup/brainPET_code/Aether-Mirror. You will have to cd to this folder before running any of the functions below.
Download and Organize MR and PET Data
This function creates the subject directory and its PET/MR/MR_PET sub-directories, download MR and/or PET data, and unpack & organize MR data. You can download old and recently acquired data (see the note below on how to download old data). It also allows you to QC TOI/ScanID/ScanDate/PI through terminal output.
For full instructions type: perl brainPET_mrpet_dwnld_unpack.pl -h
OPTIONS -d, --basedir Base directory -s, --subjid Subject ID (this will be the subject folder name) -id, --scanid Scan ID -m, --mr Downlaod MR data -p, --pet Download PET data ** All input arguments are mandatory.
Example
1 perl brainPET_mrpet_dwnld_unpack.pl -d /<DIR> -s <SubjID> -id <ScanID> -mr 1 -pet 1
To download an old subject (acquired more than 4 years ago), please do the following:
ssh to pinto.nmr.mgh.harvard.edu
- cd to where the code is located
- type: bash (and hit enter)
- re-run the script
The script automatically detects if the subject is old or recently acquired and an error message will pop up with instructions in case of old data.
PseudoCT mu-map generation
This function generates pseudoCT mu-map using SPM8 atlas-based method (David Izquierdo-Garcia et al.). This function works with both dcm or nifti files as input.
For full instructions type in a terminal (change directory (cd) to Aether-Mirror folder): perl brainPET_pCT_AeMir.pl -h
OPTIONS -i, --mprage_dir Full directory where the .dcm or .nii file exist /autofs/cluster/<space>/..../<SUBJID>/MR/MPRAGE -f, --file_name The name of the nii file or the first dcm file (add the file name with its extension). -c, --coil_choice Numerical coil ID as follows: 0 : CP Coil + 8 Ch-Coil (bay 6 optm) 1 : Small Monkey Coil + CP (bay6) 2 : Large Monkey Coil + CP (bay6) 3 : CP Coil + 8 Ch-Coil (bay8) 4 : CP Coil Only (bay8) 5 : CP Coil + 8 Ch-Coil (bay 8 optm) 6 : CP Coil + 32 Ch-Coil (bay6) 7 : No Hardware ** All input arguments are mandatory.
- For DICOM input:
1 perl brainPET_pCT_AeMir.pl -i /<DIR>/<SUJID>/MR/MPRAGE -f 107000-000005-000001.dcm -c 0
where 107000-000005-000001.dcm is the file name of the first dcm file.
- For NIFTI input
1 perl brainPET_pCT_AeMir.pl -i /<DIR>/<SUJID>/MR_PET -f cp_iso_mprage.nii -c 0
- IMP1: The r-l flip is applied only to .dcm input but not to .nii input (see Imp2)
IMP2: If you input a nifti file, it should be named as cp_iso_mprage.nii and it should be r-l flipped (i.e., it is the output of a previously ran pseudoCT).
PseudoCT Output QC
This function is to QC the output of pCT. If you access your machine remotely, please use either No Machine or VNC for better output. Don't use your mac terminal!
For full instructions type: perl brainPET_pCT_QC_AeMir.pl -h
OPTIONS -i, --subjdir Subject directory ** All input arguments are mandatory.
Example
1 perl brainPET_pCT_QC_AeMir.pl -i /<DIR>/<SUJID>
Single Frame Dual Pass
This function generates single-frame PET image files from list-mode data. It assumes a particular folder structure for it to work: Parent Folder: MR, MR_PET (> mu_maps > mu_map), PET > (list mode data). From the list mode data, TAC will generate images with a user-defined duration for a number of selectable isotopes. It first reconstructs PET frames using the native position of mu-map (1st pass) and later registers the mu-map to the position of the late PET window (e.g. 60-90 for PBR28) before the 2nd pass of reconstruction. The resulting images can be viewed as either SUV, bqml, or nas images. Mu maps must be present.
For full instructions type: perl brainPET_recon_2passSF_AeMir.pl -h
OPTIONS -i, --subject_dir Full Parent Directory (directory should stop at the subject ID) ex. /autofs/cluster/<space>/<SUBJECT_ID> The script assumes the parent directory contains: MR,MR_PET(>mu_maps>mu_map),PET>(list mode data) -s, --pet_start The starting time (sec) of the Frame of interest For 60-90 Frame this should be 3600 -d, --duration Frame duration (sec) For 60-90 Frame this should be 1800 -e, --isotope Isotope code as follows: 0 : F18 1 : Ge68 2 : Cu64 3 : O15 4 : N13 5 : C11 6 : Ga68 7 : Y86 -p, --single_pass 1: for only single-pass recon 0: for two-pass recon (recommended) In case two-pass recons selected, the output after the first pass will be output inside (Sum/1st_pass) folder. -r, --redo 1: if single frame recon is needed to re-run. 0 otherwise. ** All input arguments are mandatory.
Example
1 perl brainPET_recon_2passSF_AeMir.pl -i /<path>/<SUBJ_ID> -s 3600 -d 1800 -e 5 -p 0 -r 0
This will reconstruct a dual-pass single (60-90) mins frame for [11C] list mode data.
- IMP1: If the subject has more than one frame, no need to delete any frame -- the script recognizes the timings automatically.
Single Frame Output QC
This function to QC the output of Single Frame Reconstruction. This should run right after 2passSF code. The Sum directory will be renamed to Sum_SingleFrame and some QC windows will pop up for you to QC the output. If you access your machine remotely, please use either No Machine or VNC for better output. For now, please don't use your mac terminal.
For full instructions type: perl brainPET_SF_QC_AeMir.pl -h
OPTIONS -i, --subjdir Subject directory ** All input arguments are mandatory.
Example
1 perl brainPET_SF_QC_AeMir.pl -i /<DIR>/<SUJID>
Dynamic Frame Reconstruction (TAC)
This function generates single-frame PET image files from list-mode data. It assumes a particular folder structure for it to work: Parent Folder: MR, MR_PET (> mu_maps > mu_map), PET > (list mode data). From the list mode data, TAC will generate images with a user-defined duration for a number of selectable isotopes. The resulting images can be viewed as either SUV, bqml, or nas images. Mu maps must be present.
For full instructions type: perl brainPET_recon_DF_AeMir.pl -h
OPTIONS -i, --subject_dir Full Parent Directory (directory should stop at the subject ID) ex. /autofs/cluster/<space>/<SUBJECT_ID> The script assumes the parent directory contains: MR,MR_PET(>mu_maps>mu_map),PET>(list mode data) -s, --pet_start The starting time (sec) of the Frame of interest For 60-90 Frame this should be 3600 -d, --duration Frame duration (sec) For 60-90 Frame this should be 1800 -e, --isotope Isotope code as follows: 0 : F18 1 : Ge68 2 : Cu64 3 : O15 4 : N13 5 : C11 6 : Ga68 7 : Y86 -p, --single_pass 1: for only single-pass recon 0: for two-pass recon (recommended) In case two-pass recons selected, the output after the first pass will be output inside (Sum/1st_pass) folder. -r, --redo 1: if single frame recon is needed to re-run. 0 otherwise. ** All input arguments are mandatory.
Example
1 perl brainPET_recon_DF_AeMir.pl -i /<full_path>/<subj_id>/PET -f Frame1.lst -d dynamic_frame_list.txt -e 5 -s '[1 0 1]' -t 0.8
This will reconstruct dynamic frame PET image according to frames length indicated in dynamic_frame_list.txt (which should be located inside PET folder) for [11C] list mode data (Frame1.lst). It will output both SUV and SUV_BQML.
Blood Data Processing (for Kinetic Modeling)
Usage Note
This section is to process Blood data (Bay 6 + Bay 7) acquired at the Athinoula A. Martinos Center for Biomedical Imaging.
Gamma Bomb Blood Data Processing
This function is to process blood data acquired at Bay 06 or Bay 07. It reads automatic gamma counter data for AIF arterial, venous whole blood, and plasma samples and sorts them into a readable format. It assumes a particular folder structure for it to work: Parent Folder>MR, PET>(list mode data), Blood>(Blood raw excel and csv files) From the gamma output data and blood samples timing sheets, this function will correct for isotope decay and write data into readable formats. You have options to insert a specific background activity, fit Feng and Lin_3exp models to the data, and correct for bolus arrival time (BAT).
For full instructions type in a terminal (change directory (cd) to Aether-Mirror folder): perl bld_gamma_bomb.pl -h
OPTIONS -i, --subject_dir Full Parent Directory ex. /autofs/cluster/<space>/<SUBJECT_ID> The script assumes the parent directory contains: MR,PET>(list mode data), Blood (excel and csv blood files) -temp, --template The name of csv file with automatic gamma counter sample information should include file extension (.xlsx) -tr, --tracer Isotope name (either c-11 or f-18) -met, --metcor 1: to do metabolite correction 0: otherwise (recommended) [metabolite correction should be done using a separate function] -bkgnd, --bkgndAct 'x': to use the background activity in the csv file (gamma reading output). Otherwise the number you enter will be used as a background activity value -bat, --batcor 1: to correct for BAT (for this it needs list mode data inside the PET folder) 0: otherwise -fit, --dofit 1: Do Feng and Lin_3exp fitting 0: for InviCRO trials where fitting is not needed ** All input arguments are mandatory.
Example
1 perl bld_gamma_bomb.pl -i /<path>/<SUBJ_ID> -temp <>.xlsx -tr c-11 -met 0 -bkgnd x -bat 0 -fit 1
This will process the blood data for c-11 isotope and will fit Feng and L3Exp models (without correction for BAT)
- IMP1: For InviCRO's trials, use -fit 0.
Supporting Functions
Denoise MPRAGE
This function performs thresholding-based denoising for the MPRAGE image to clean it for better pseudo-CT results. Use it only if the mprage is noisy. It works only with nifti (.nii) file as input. It takes a denoising threshold (intensity) to remove noise in the image, and a Gauss smoothing factor (mm) to facilitate denoising.
For full instructions type: perl brainPET_denoise_mprage.pl -h
OPTIONS -i, --mprage File name and directory -t, --thres Denoising threshold (typically starts with 25 and could be increased by 5 until sufficient denoising result is achieved) -s, --smooth Smoothing factor (mm), 4 is a typical value. you may input 0 to skip smoothing. ** All input arguments are mandatory. Ex1: perl brainPET_denoise_mprage.pl -i /<DIR>/<SUJID>/MR_PET/cp_iso_mprage.nii -t 25 -s 0 Outputs: cp_iso_mprage_denoised_thres<>_smooth<>mm.nii and scp_iso_mprage.nii (this is the smoothed version of the input image, it should be identical to the input, if the smoothing was set to 0). The output is saved in the same folder as the input. Use the final denoised image as input into the pseudo CT script (brainPET_pCT.pl). Imp1: The input nifti file is preferred to be named as cp_iso_mprage.nii and it should be r-l flipped (i.e., it is the output of a previously ran pseudo CT).
Example
1 perl brainPET_denoise_mprage.pl -i /<DIR>/<SUBJID>/MR_PET/cp_iso_mprage.nii -t 25 -s 0
Outputs: cp_iso_mprage_denoised_thres<>_smooth<>mm.nii and scp_iso_mprage.nii (this is the smoothed version of the input image, it should be identical to the input if the smoothing was set to 0). The output is saved in the same folder as the input.
ifile2nifti
This function converts brainPET ifile to nifit format.
For full instructions type: perl brainPET_ifile2nifti.pl -h
OPTIONS -i, --filedir File directory ** All input arguments are mandatory.
Example
1 perl brainPET_ifile2nifti.pl -i /<DIR>/file.i
Resample ifile
This function resamples ifiles to [1 1 1] and kills a user-defined number of planes from top and bottom.
For full instructions type: perl brainPET_ifile_resample.pl -h
OPTIONS -i, --dir Directory where ifiles (frame*_nas_suv.i) exist -t, --top Number of planes to be killed from top -b, --bottom Number of planes to be killed from bottom ** All input arguments are mandatory.
Example
1 perl perl brainPET_ifile_resample.pl -i /<DIR>/PET/Sum/TAC_SUV -t 3 -b 2
Volviewer (ifile)
This function to view i-files using volviewer. If you access your machine remotely, please use either No Machine or VNC for better output. Don't use your mac terminal!
For full instructions type: perl brainPET_volviewer.pl -h
OPTIONS -i, --filedir File directory ** All input arguments are mandatory.
Example
1 perl brainPET_volviewer.pl -i /<DIR>/<filename>.i
Mapviewer (dcmap file)
This function to view dcmap files using mapviewer. If you access your machine remotely, please use either No Machine or VNC for better output. Don't use your mac terminal!
For full instructions type: perl brainPET_mapviewer.pl -h
OPTIONS -i, --filedir File directory ** All input arguments are mandatory.
Example
1 perl brainPET_mapviewer.pl -i /<DIR>/<filename>.dcmap
Development Version
UNDER CONSTRUCTION !!