-
Notifications
You must be signed in to change notification settings - Fork 31
HCP Pipelines Improvements (ICAFIX, PostFix, RestingStateStats, TaskfMRIAnalysis, londitudinal/cross-sectional logic) #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
ce2c6db
56f01cb
8f46b5b
53d615b
3b23b48
4f98e77
8ac3dad
6c61788
bbab867
b91946f
4696caa
197e040
937bc62
35e86d3
ae79bb6
8b5e288
3f0c1ea
6378f36
dc33ab0
5fbf323
d52473d
f47ac58
16861b9
fdc426f
ab32ac1
1cc0c75
5118fd3
eaead66
07d8b30
8b06f71
1460c75
41efa1c
47199c3
64a75ba
a189963
7bd1b56
cc17817
2275f9b
2179add
a16f9b3
3c6f2ef
0f83447
36193db
bf9ea23
f396d16
fbf253a
31dbef0
d338bc8
7bc3a05
2890771
f27050f
2c50592
3af4730
25ee198
9401eed
dd20804
4292ebc
873f47e
cf17e6a
782df47
86e10e2
943afa0
856e95c
b939175
dd17549
5401cc6
8b5c071
9ac1544
a8675c3
35cbd7d
ad5fc48
156b66a
ce466ce
23a4e6f
2048ab4
0d40451
2e3a4c9
3b1b3dc
e67b1cd
cec30da
5a0b02f
6b0502d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"/.idea" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,36 @@ | ||
# Use Ubuntu 14.04 LTS | ||
FROM ubuntu:trusty-20170119 | ||
|
||
# Configure environment | ||
ENV OS Linux | ||
ENV FS_OVERRIDE 0 | ||
ENV FIX_VERTEX_AREA= | ||
ENV SUBJECTS_DIR /opt/freesurfer/subjects | ||
ENV FSF_OUTPUT_FORMAT nii.gz | ||
ENV MNI_DIR /opt/freesurfer/mni | ||
ENV LOCAL_DIR /opt/freesurfer/local | ||
ENV FREESURFER_HOME /opt/freesurfer | ||
ENV FSFAST_HOME /opt/freesurfer/fsfast | ||
ENV MINC_BIN_DIR /opt/freesurfer/mni/bin | ||
ENV MINC_LIB_DIR /opt/freesurfer/mni/lib | ||
ENV MNI_DATAPATH /opt/freesurfer/mni/data | ||
ENV FMRI_ANALYSIS_DIR /opt/freesurfer/fsfast | ||
ENV PERL5LIB /opt/freesurfer/mni/lib/perl5/5.8.5 | ||
ENV MNI_PERL5LIB /opt/freesurfer/mni/lib/perl5/5.8.5 | ||
ENV PATH /opt/freesurfer/bin:/opt/freesurfer/fsfast/bin:/opt/freesurfer/tktools:/opt/freesurfer/mni/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH | ||
ENV PYTHONPATH="" | ||
ENV FSL_FIXDIR /opt/fix | ||
ENV FSLDIR=/usr/share/fsl/5.0 | ||
ENV FSL_DIR="${FSLDIR}" | ||
ENV FSLOUTPUTTYPE=NIFTI_GZ | ||
ENV PATH=/usr/lib/fsl/5.0:$PATH | ||
ENV FSLMULTIFILEQUIT=TRUE | ||
ENV POSSUMDIR=/usr/share/fsl/5.0 | ||
ENV LD_LIBRARY_PATH=/usr/lib/fsl/5.0 | ||
ENV FSLTCLSH=/usr/bin/tclsh | ||
ENV FSLWISH=/usr/bin/wish | ||
ENV FSLOUTPUTTYPE=NIFTI_GZ | ||
|
||
# Download FreeSurfer | ||
RUN apt-get -y update \ | ||
&& apt-get install -y wget && \ | ||
|
@@ -20,115 +50,100 @@ RUN apt-get -y update \ | |
--exclude='freesurfer/lib/qt' && \ | ||
apt-get install -y tcsh bc tar libgomp1 perl-modules curl | ||
|
||
# Set up the environment | ||
ENV OS=Linux \ | ||
FS_OVERRIDE=0 \ | ||
FIX_VERTEX_AREA= \ | ||
SUBJECTS_DIR=/opt/freesurfer/subjects \ | ||
FSF_OUTPUT_FORMAT=nii.gz \ | ||
MNI_DIR=/opt/freesurfer/mni \ | ||
LOCAL_DIR=/opt/freesurfer/local \ | ||
FREESURFER_HOME=/opt/freesurfer \ | ||
FSFAST_HOME=/opt/freesurfer/fsfast \ | ||
MINC_BIN_DIR=/opt/freesurfer/mni/bin \ | ||
MINC_LIB_DIR=/opt/freesurfer/mni/lib \ | ||
MNI_DATAPATH=/opt/freesurfer/mni/data \ | ||
FMRI_ANALYSIS_DIR=/opt/freesurfer/fsfast \ | ||
PERL5LIB=/opt/freesurfer/mni/lib/perl5/5.8.5 \ | ||
MNI_PERL5LIB=/opt/freesurfer/mni/lib/perl5/5.8.5 \ | ||
PATH=/opt/freesurfer/bin:/opt/freesurfer/fsfast/bin:/opt/freesurfer/tktools:/opt/freesurfer/mni/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH | ||
|
||
|
||
# https://bugs.debian.org/830696 (apt uses gpgv by default in newer releases, rather than gpg) | ||
RUN set -x \ | ||
&& apt-get update \ | ||
&& { \ | ||
which gpg \ | ||
|| apt-get install -y --no-install-recommends gnupg \ | ||
; } \ | ||
# Ubuntu includes "gnupg" (not "gnupg2", but still 2.x), but not dirmngr, and gnupg 2.x requires dirmngr | ||
# so, if we're not running gnupg 1.x, explicitly install dirmngr too | ||
&& { \ | ||
gpg --version | grep -q '^gpg (GnuPG) 1\.' \ | ||
|| apt-get install -y --no-install-recommends dirmngr \ | ||
; } \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# apt-key is a bit finicky during "docker build" with gnupg 2.x, so install the repo key the same way debian-archive-keyring does (/etc/apt/trusted.gpg.d) | ||
# this makes "apt-key list" output prettier too! | ||
RUN set -x \ | ||
&& export GNUPGHOME="$(mktemp -d)" \ | ||
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys DD95CC430502E37EF840ACEEA5D32F012649A5A9 \ | ||
&& gpg --export DD95CC430502E37EF840ACEEA5D32F012649A5A9 > /etc/apt/trusted.gpg.d/neurodebian.gpg \ | ||
&& rm -rf "$GNUPGHOME" \ | ||
&& apt-key list | grep neurodebian | ||
|
||
RUN { \ | ||
echo 'deb http://neuro.debian.net/debian trusty main'; \ | ||
echo 'deb http://neuro.debian.net/debian data main'; \ | ||
echo '#deb-src http://neuro.debian.net/debian-devel trusty main'; \ | ||
} > /etc/apt/sources.list.d/neurodebian.sources.list | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you want to remove this? It's an important workaround for flaky key server. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Obviously I did not understand the purpose of this. Feel free to leave it in! |
||
|
||
RUN sed -i -e 's,main *$,main contrib non-free,g' /etc/apt/sources.list.d/neurodebian.sources.list; grep -q 'deb .* multiverse$' /etc/apt/sources.list || sed -i -e 's,universe *$,universe multiverse,g' /etc/apt/sources.list | ||
|
||
# Install FSL 5.0.9 | ||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends curl && \ | ||
curl -sSL http://neuro.debian.net/lists/trusty.us-ca.full >> /etc/apt/sources.list.d/neurodebian.sources.list && \ | ||
apt-key adv --recv-keys --keyserver hkp://pgp.mit.edu:80 0xA5D32F012649A5A9 && \ | ||
apt-get update && \ | ||
apt-get install -y fsl-core=5.0.9-4~nd14.04+1 | ||
curl -sSL http://neuro.debian.net/lists/trusty.us-ca.full >> /etc/apt/sources.list.d/neurodebian.sources.list | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See comment above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my comment above. |
||
|
||
# Configure environment | ||
ENV FSLDIR=/usr/share/fsl/5.0 | ||
ENV FSL_DIR="${FSLDIR}" \ | ||
FSLOUTPUTTYPE=NIFTI_GZ \ | ||
PATH=/usr/lib/fsl/5.0:$PATH \ | ||
FSLMULTIFILEQUIT=TRUE \ | ||
POSSUMDIR=/usr/share/fsl/5.0 \ | ||
LD_LIBRARY_PATH=/usr/lib/fsl/5.0:$LD_LIBRARY_PATH \ | ||
FSLTCLSH=/usr/bin/tclsh \ | ||
FSLWISH=/usr/bin/wish \ | ||
FSLOUTPUTTYPE=NIFTI_GZ | ||
RUN apt-key adv --recv-keys --keyserver hkp://pgp.mit.edu:80 0xA5D32F012649A5A9 | ||
|
||
RUN echo "cHJpbnRmICJrcnp5c3p0b2YuZ29yZ29sZXdza2lAZ21haWwuY29tXG41MTcyXG4gKkN2dW12RVYzelRmZ1xuRlM1Si8yYzFhZ2c0RVxuIiA+IC9vcHQvZnJlZXN1cmZlci9saWNlbnNlLnR4dAo=" | base64 -d | sh | ||
RUN apt-get update && \ | ||
apt-get install -y fsl-core=5.0.9-4~nd14.04+1 | ||
|
||
RUN apt-get build-dep -y gridengine && apt-get update -y | ||
|
||
# Install Connectome Workbench | ||
RUN apt-get update && apt-get -y install connectome-workbench=1.2.3-1~nd14.04+1 | ||
|
||
ENV CARET7DIR=/usr/bin | ||
|
||
# Install HCP Pipelines and MSM binaries | ||
WORKDIR /opt | ||
RUN apt-get -y update \ | ||
# Install HCP Pipelines | ||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends python-numpy && \ | ||
wget -q https://github.com/Washington-University/Pipelines/archive/v3.17.0.tar.gz -O pipelines.tar.gz && \ | ||
tar zxf pipelines.tar.gz && \ | ||
mv /opt/Pipelines-* /opt/HCP-Pipelines && \ | ||
rm pipelines.tar.gz && \ | ||
wget -q https://www.doc.ic.ac.uk/~ecr05/MSM_HOCR_v1/MSM_HOCR_v1-download.tgz -O MSMs.tar.gz && \ | ||
tar zxf MSMs.tar.gz && \ | ||
rm MSMs.tar.gz && \ | ||
mv MSM_HOCR_v1/Ubuntu /opt/HCP-Pipelines/MSMBinaries && \ | ||
rm -rf MSM_HOCR_v1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason for not installing MSM? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No reason, let's go with your version. |
||
|
||
WORKDIR / | ||
|
||
wget https://github.com/Washington-University/Pipelines/archive/v3.17.0.tar.gz -O pipelines.tar.gz && \ | ||
cd /opt/ && \ | ||
mkdir /opt/HCP-Pipelines && \ | ||
tar zxf /pipelines.tar.gz -C /opt/HCP-Pipelines --strip-components=1 && \ | ||
rm /pipelines.tar.gz | ||
|
||
# Install FIX | ||
RUN apt-get update && apt-get install -y build-essential libpcre3 libpcre3-dev fort77 xorg-dev libbz2-dev liblzma-dev libblas-dev gfortran gcc-multilib gobjc++ libreadline-dev bzip2 libcurl4-gnutls-dev default-jdk gdebi | ||
|
||
RUN cd /opt && \ | ||
wget http://www.fmrib.ox.ac.uk/~steve/ftp/fix.tar.gz && \ | ||
tar zxvf fix.tar.gz && \ | ||
rm fix.tar.gz | ||
RUN mv /opt/fix* /opt/fix | ||
|
||
RUN cd /opt && \ | ||
wget https://cloud.r-project.org/bin/linux/ubuntu/trusty/r-base-core_3.4.4-1trusty0_amd64.deb && \ | ||
wget https://cloud.r-project.org/bin/linux/ubuntu/trusty/r-base-dev_3.4.4-1trusty0_all.deb && \ | ||
gdebi -n r-base-core_3.4.4-1trusty0_amd64.deb && \ | ||
gdebi -n r-base-dev_3.4.4-1trusty0_all.deb && \ | ||
apt-get install -y libssl-dev | ||
|
||
RUN R --vanilla -e "install.packages('coin', repos='http://cran.us.r-project.org', dependencies=TRUE)" -e "install.packages('strucchange', repos='http://cran.us.r-project.org', dependencies=TRUE)" -e "install.packages('https://cran.r-project.org/src/contrib/Archive/party/party_1.0-25.tar.gz', repos=NULL, type='source')" -e "install.packages('https://cran.r-project.org/src/contrib/Archive/kernlab/kernlab_0.9-24.tar.gz', repos=NULL, type='source')" -e "install.packages('ROCR', repos='http://cran.us.r-project.org', dependencies=TRUE)" -e "install.packages('https://cran.r-project.org/src/contrib/Archive/e1071/e1071_1.6-7.tar.gz', repos=NULL, type='source')" -e "install.packages('https://cran.r-project.org/src/contrib/Archive/randomForest/randomForest_4.6-12.tar.gz', repos=NULL, type='source')" | ||
|
||
RUN mkdir /tmp/v83 && \ | ||
cp /opt/fix*/compiled/Linux/x86_64/MCRInstaller.zip /tmp/v83 && \ | ||
cd /tmp/v83 && \ | ||
unzip MCRInstaller.zip | ||
|
||
COPY modified_files/MCR_installer_input_v83.txt /tmp/v83/MCR_installer_input.txt | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you elaborate on the changes required to this file? It might be clearer to apply them via |
||
RUN cd /tmp/v83 && ./install -mode silent -inputFile MCR_installer_input.txt | ||
|
||
# Ensure Dependencies for PostFix are met | ||
RUN apt-get update | ||
RUN mkdir /tmp/v81 && \ | ||
cd /tmp/v81 && \ | ||
wget http://ssd.mathworks.com/supportfiles/MCR_Runtime/R2013a/MCR_R2013a_glnxa64_installer.zip && \ | ||
unzip MCR_R2013a_glnxa64_installer.zip | ||
COPY modified_files/MCR_installer_input_v81.txt /tmp/v81/MCR_installer_input.txt | ||
RUN cd /tmp/v81 && ./install -mode silent -inputFile MCR_installer_input.txt | ||
|
||
#Create necessary environment variables | ||
RUN echo "cHJpbnRmICJrcnp5c3p0b2YuZ29yZ29sZXdza2lAZ21haWwuY29tXG41MTcyXG4gKkN2dW12RVYzelRmZ1xuRlM1Si8yYzFhZ2c0RVxuIiA+IC9vcHQvZnJlZXN1cmZlci9saWNlbnNlLnR4dAo=" | base64 -d | sh | ||
ENV CARET7DIR=/usr/bin | ||
ENV HCPPIPEDIR=/opt/HCP-Pipelines | ||
ENV HCPPIPEDIR_Templates=${HCPPIPEDIR}/global/templates \ | ||
HCPPIPEDIR_Bin=${HCPPIPEDIR}/global/binaries \ | ||
HCPPIPEDIR_Config=${HCPPIPEDIR}/global/config \ | ||
HCPPIPEDIR_PreFS=${HCPPIPEDIR}/PreFreeSurfer/scripts \ | ||
HCPPIPEDIR_FS=${HCPPIPEDIR}/FreeSurfer/scripts \ | ||
HCPPIPEDIR_PostFS=${HCPPIPEDIR}/PostFreeSurfer/scripts \ | ||
HCPPIPEDIR_fMRISurf=${HCPPIPEDIR}/fMRISurface/scripts \ | ||
HCPPIPEDIR_fMRIVol=${HCPPIPEDIR}/fMRIVolume/scripts \ | ||
HCPPIPEDIR_tfMRI=${HCPPIPEDIR}/tfMRI/scripts \ | ||
HCPPIPEDIR_dMRI=${HCPPIPEDIR}/DiffusionPreprocessing/scripts \ | ||
HCPPIPEDIR_dMRITract=${HCPPIPEDIR}/DiffusionTractography/scripts \ | ||
HCPPIPEDIR_Global=${HCPPIPEDIR}/global/scripts \ | ||
HCPPIPEDIR_tfMRIAnalysis=${HCPPIPEDIR}/TaskfMRIAnalysis/scripts \ | ||
MSMBin=${HCPPIPEDIR}/MSMBinaries | ||
ENV HCPPIPEDIR_Templates=${HCPPIPEDIR}/global/templates | ||
ENV HCPPIPEDIR_Bin=${HCPPIPEDIR}/global/binaries | ||
ENV HCPPIPEDIR_Config=${HCPPIPEDIR}/global/config | ||
ENV HCPPIPEDIR_PreFS=${HCPPIPEDIR}/PreFreeSurfer/scripts | ||
ENV HCPPIPEDIR_FS=${HCPPIPEDIR}/FreeSurfer/scripts | ||
ENV HCPPIPEDIR_PostFS=${HCPPIPEDIR}/PostFreeSurfer/scripts | ||
ENV HCPPIPEDIR_fMRISurf=${HCPPIPEDIR}/fMRISurface/scripts | ||
ENV HCPPIPEDIR_fMRIVol=${HCPPIPEDIR}/fMRIVolume/scripts | ||
ENV HCPPIPEDIR_tfMRI=${HCPPIPEDIR}/tfMRI/scripts | ||
ENV HCPPIPEDIR_dMRI=${HCPPIPEDIR}/DiffusionPreprocessing/scripts | ||
ENV HCPPIPEDIR_dMRITract=${HCPPIPEDIR}/DiffusionTractography/scripts | ||
ENV HCPPIPEDIR_Global=${HCPPIPEDIR}/global/scripts | ||
ENV HCPPIPEDIR_tfMRIAnalysis=${HCPPIPEDIR}/TaskfMRIAnalysis/scripts | ||
ENV MSMBin=${HCPPIPEDIR}/MSMBinaries | ||
|
||
# Install python Dependencies | ||
RUN apt-get update && apt-get install -y --no-install-recommends python-pip python-six python-nibabel python-setuptools | ||
RUN pip install pybids==0.5.1 | ||
RUN pip install --upgrade pybids | ||
|
||
|
||
#make /bids_dir and /output_dir | ||
RUN mkdir /bids_dir && \ | ||
mkdir /output_dir | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this necessary? |
||
|
||
#create 360CortSurf_19Vol_parcel.dlabel.nii | ||
RUN cd / && \ | ||
wget https://github.umn.edu/hendr522/HCPPipelines/blob/master/modified_files/360CortSurf_19Vol_parcel.dlabel.nii | ||
|
||
## Install the validator | ||
RUN apt-get update && \ | ||
|
@@ -144,7 +159,17 @@ RUN pip install pybids==0.5.1 | |
ENV PYTHONPATH="" | ||
|
||
COPY run.py /run.py | ||
RUN chmod +x /run.py | ||
RUN chmod 555 /run.py | ||
|
||
COPY version /version | ||
COPY IntendedFor.py /IntendedFor.py | ||
COPY modified_files/fsl_sub /usr/lib/fsl/5.0/fsl_sub | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What changes are required to this file? It would be better to apply them via |
||
COPY modified_files/settings.sh /opt/fix/settings.sh | ||
COPY modified_files/360CortSurf_19Vol_parcel.dlabel.nii /360CortSurf_19Vol_parcel.dlabel.nii | ||
COPY modified_files/PostFix.sh /opt/HCP-Pipelines/PostFix/PostFix.sh | ||
COPY modified_files/run_prepareICAs.sh /opt/HCP-Pipelines/PostFix/Compiled_prepareICAs/distrib/run_prepareICAs.sh | ||
COPY modified_files/RestingStateStats.sh /opt/HCP-Pipelines/RestingStateStats/RestingStateStats.sh | ||
COPY modified_files/run_RestingStateStats.sh /opt/HCP-Pipelines/RestingStateStats/Compiled_RestingStateStats/distrib/run_RestingStateStats.sh | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like to avoid departing from the original HCP Pipelines as much as possible. Why those files need to be replaced? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generally I absolutely agree with you, however, I was required to make mods to the RestingStateStats and PostFix scripts because the paths to the matlab compiler runtime are hardcoded to paths that fall within WashU's server systems. |
||
|
||
|
||
ENTRYPOINT ["/run.py"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
|
||
#!/usr/bin/python | ||
import json | ||
import os | ||
from glob import glob | ||
import numpy | ||
|
||
""" | ||
This script is designed to determine which field maps apply to discrete fMRI scans | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks very similar to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. It has been a while since I looked at the get_fieldmap function implemented in pybids so perhaps it has changed, but doesn't the get_fieldmap function just retrieve the fieldmap in which the fmriname is within the "IntendedFor" field? I was under the impression that the "IntendedFor" field does not automatically generate through the BIDS conversion, thus it has to be added manually. What am I missing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. Maybe I misunderstood what your function does. If it's part of a conversion process this repo might not be the best place for it. Maybe it would be better to put it in pybids? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can see why you may have been confused. The comments I provide I very unclear. Obviously I created them when I did not understand what the script was doing myself, and forgot to come through and change them. It is added the "IntendedFor" fields to the fmap json sidecars, so yes I suppose it has more to do with the BIDS conversion. I can propose incorporation to pybids, but perhaps as a catch-all let's leave IntendedFor..py as is for now. |
||
|
||
Author - Timothy J Hendrickson | ||
""" | ||
|
||
def setup(subject_path): | ||
if "ses" in os.listdir(subject_path)[0]: | ||
for item in (os.listdir(subject_path)): | ||
session_path = subject_path + '/'+ item | ||
IntendedFor(session_path) | ||
IntendedFor(subject_path) | ||
|
||
def IntendedFor(data_path): | ||
for fmap in sorted(glob(data_path+'/fmap/*.json')): | ||
with open(fmap, 'r') as f: | ||
fmap_json = json.load(f) | ||
f.close() | ||
if "IntendedFor" in fmap_json: | ||
del fmap_json["IntendedFor"] | ||
shim_fmap = fmap_json["ShimSetting"] | ||
patient_pos_fmap = fmap_json["ImageOrientationPatientDICOM"] | ||
func_list = [] | ||
for func in sorted(glob(data_path+'/func/*bold.json')): | ||
with open(func, 'r') as g: | ||
func_json = json.load(g) | ||
shim_func = func_json["ShimSetting"] | ||
patient_pos_func = func_json["ImageOrientationPatientDICOM"] | ||
g.close() | ||
if shim_fmap == shim_func: | ||
func_nii = glob(data_path+'/func/' +func.split('/')[-1].split('.')[0]+".nii*")[0] | ||
if "ses" in data_path: | ||
func_nii = "/".join(func_nii.split("/")[-3:]) | ||
func_list.append(func_nii) | ||
else: | ||
func_nii = "/".join(func_nii.split("/")[-2:]) | ||
func_list.append(func_nii) | ||
#elif patient_pos_fmap == patient_pos_func: | ||
# shim_func_np = numpy.array(shim_func) | ||
# shim_fmap_np = numpy.array(shim_fmap) | ||
# diff_shims = shim_fmap_np - shim_func_np | ||
# print("difference between fieldmap and functional scan is " + str(sum(abs(diff_shims)))) | ||
# user_input = raw_input("Do you accept this difference? [y/n]: ") | ||
# if user_input == 'y': | ||
# func_nii = glob(data_path + '/func/' + func.split('/')[-1].split('.')[0] + ".nii*")[0] | ||
# if "ses" in data_path: | ||
# func_nii = "/".join(func_nii.split("/")[-3:]) | ||
# func_list.append(func_nii) | ||
# else: | ||
# func_nii = "/".join(func_nii.split("/")[-2:]) | ||
# func_list.append(func_nii) | ||
# else: | ||
# print(fmap + " does not have match yet...") | ||
entry = {"IntendedFor": func_list} | ||
|
||
fmap_json.update(entry) | ||
with open(fmap, 'w') as f: | ||
json.dump(fmap_json, f) | ||
f.close() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there a reason for moving this here?