Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 15397e3

Browse files
committed
Add MSMSulc support
1 parent 45bb1af commit 15397e3

File tree

5 files changed

+38
-13
lines changed

5 files changed

+38
-13
lines changed

Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,13 @@ RUN apt-get -y update \
134134
ENV HCPPIPEDIR=/opt/HCP-Pipelines
135135

136136
#############################################
137-
# Install MSM binaries (from local directory)
138-
ENV MSMBin=${HCPPIPEDIR}/MSMBinaries
137+
# Download amnd install MSM_HOCR v3 binary
138+
ENV MSMBINDIR=${HCPPIPEDIR}/MSMBinaries
139+
140+
RUN mkdir -p ${MSMBINDIR} && \
141+
wget -nv https://github.com/ecr05/MSM_HOCR_macOSX/releases/download/1.0/msm_ubuntu14.04 -O ${MSMBINDIR}/msm && \
142+
chmod +x ${MSMBINDIR}/msm
139143

140-
# Copy MSM_HOCR_v2 binary
141-
# Skip this for now pending license questions
142-
#COPY MSM/Centos/msm ${MSMBin}/msm
143144
#############################################
144145

145146
# Make directory for flywheel spec (v0)

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222
* If needed, this file can be obtained from the console at <code>C:\MedCom\MriSiteData\GradientCoil\coeff.grad</code> for Siemens scanners
2323
* Note: This effect is significant for HCP data collected on custom Siemens "ConnectomS" scanner, and for 7T scanners. It is relatively minor for production 3T scanners (Siemens Trio, Prisma, etc.)
2424

25+
## Configuration options
26+
1. Subject: Subject ID to use for outputs
27+
2. RegName: Surface registration type: either 'FS' (freesurfer) or 'MSMSulc' (HCP default). (See [FSL MSM](https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/MSM) for details on MSMSulc)
28+
3. BrainSize: Brain size in mm (in Superior-Inferior axis), typically 150 (default) for adults
29+
4. TemplateSize: Voxel size of HCP anatomical template. Best if matches input. (Options = 0.7mm, 0.8mm (default), 1mm)
30+
5. StructuralUnwarpDirection: Readout direction for structural scans ( 'x', 'x-', 'y', 'y-', 'z', 'z-' ). HCP default = 'z' (**Only used when providing fieldmaps to correct readout distortion**)
31+
2532
## Outputs
2633
* <code>\<subject\>\_hcpstruct.zip</code>: Zipped output directory containing complete <code>MNINonLinear/</code>, <code>T1w/</code>, and <code>T2w/</code> folders.
2734
* <code>\<subject\>\_hcpstruct\_QC.*.png</code>: QC images for visual inspection of output quality (details to come...)

manifest.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@
8787
"default": "000000",
8888
"description": "Subject ID (Default = 000000)"
8989
},
90+
"RegName": {
91+
"type": "string",
92+
"default": "MSMSulc",
93+
"description": "Surface registration type: either 'FS' (freesurfer) or 'MSMSulc' (HCP default)"
94+
},
9095
"BrainSize": {
9196
"type": "integer",
9297
"default": 150,

run

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ mkdir -p ${LogFileDirFull}
5959
FSLSUBOPTIONS="-l ${LogFileDirFull}"
6060

6161
#Default Config Settings
62+
RegName="FS"
6263
StructuralUnwarpDir="z" #z appears to be best or "NONE" if not used
6364
StructuralDeltaTE="NONE" #DeltaTE for GRE fieldmap used to correct STRUCTURAL
6465
StructuralDwellTime="NONE" # DwellTime for SpinEchoFieldMap when TOPUP is used for STRUCTURAL (ie: not T1wSampleSpacing)
@@ -182,13 +183,22 @@ fi
182183

183184
# Install FreeSurfer license
184185
if [[ -e "${FW_INPUT_FreeSurferLicense}" ]]; then
185-
echo -e "$CONTAINER Copying user-supplied FreeSurfer license file to ${FREESURFER_HOME}/license.txt"
186+
echo -e "$CONTAINER [$(timestamp)] Copying user-supplied FreeSurfer license file to ${FREESURFER_HOME}/license.txt"
186187
cp -f "${FW_INPUT_FreeSurferLicense}" ${FREESURFER_HOME}/license.txt
187188
fi
188189

190+
# Check RegName config
191+
case $(toupper "${FW_CONFIG_RegName}") in
192+
FS|MSMSULC)
193+
RegName="${FW_CONFIG_RegName}"
194+
;;
195+
*)
196+
echo -e "$CONTAINER [$(timestamp)] RegName must be FS or MSMSulc!"
197+
exit 1
198+
;;
199+
esac
200+
189201
Subject=${FW_CONFIG_Subject}
190-
RegName="FS" #Only allow FreeSurfer surface registration pending MSM license questions
191-
#RegName=${FW_CONFIG_RegName}
192202
BrainSize=${FW_CONFIG_BrainSize}
193203
TemplateSize=${FW_CONFIG_TemplateSize}
194204
UnwarpDir=${FW_CONFIG_StructuralUnwarpDirection}
@@ -399,10 +409,10 @@ fi
399409
# new element called ".config" so the new file can be read as though it was flywheel config.json
400410
OUTPUT_CONFIG_FILE=${StudyFolder}/${Subject}/${Subject}_hcpstruct_config.json
401411
jq -r '.config.RegName = "'"${RegName}"'" | .config.Subject = "'"${Subject}"'" | .config | {config: .}' $CONFIG_FILE \
402-
| jq -r '.config.FinalfMRIResolution = "'"${FinalfMRIResolution}"'"' \
403412
| jq -r '.config.GrayordinatesResolution = "'"${GrayordinatesResolution}"'"' \
404-
| jq -r '.config.LowResMesh = "'"${LowResMesh}"'"' \
405-
| jq -r '.config.SmoothingFWHM = "'"${SmoothingFWHM}"'"' > ${OUTPUT_CONFIG_FILE}
413+
| jq -r '.config.GrayordinatesTemplate = "'"${GrayordinatesTemplate}"'"' \
414+
| jq -r '.config.HighResMesh = "'"${HighResMesh}"'"' \
415+
| jq -r '.config.LowResMesh = "'"${LowResMesh}"'"' > ${OUTPUT_CONFIG_FILE}
406416

407417
# If pipeline successful, zip outputs and clean up
408418
outputzipname=${Subject}_hcpstruct.zip

scripts/bash_functions.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#needed to clean up some of the numerical config options (if empty or non-numerical, output empty)
2-
print_decimal_number () { echo $1 | awk '{if($1*1 == $1) printf "%.15f\n", $1; else print ""}'; };
3-
2+
#optional second input = number of decimal places (Default = 15)
3+
print_decimal_number () { dec=$(echo $2 15 | awk '{print $1}'); echo $1 | awk '{if($1*1 == $1) printf "%.'${dec}'f\n", $1; else print ""}'; };
44
timestamp () { date +"%Y-%m-%d %H:%M:%S %Z"; }
5+
toupper() { echo "$@" | tr '[:lower:]' '[:upper:]'; };
6+
tolower() { echo "$@" | tr '[:upper:]' '[:lower:]'; };

0 commit comments

Comments
 (0)