Skip to content

Commit

Permalink
Merge pull request #181 from bbfrederick/refinedelay
Browse files Browse the repository at this point in the history
Refinedelay
  • Loading branch information
bbfrederick authored Nov 15, 2024
2 parents de71790 + 80b196b commit 4d42b8a
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 8 deletions.
19 changes: 14 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,29 @@ RUN ldconfig
# clean up
RUN pip cache purge

# switch to the rapidtide user
RUN useradd -m -s /bin/bash -G users rapidtide
RUN chown -R rapidtide /src/rapidtide
WORKDIR /home/rapidtide
# Create a shared $HOME directory
ENV USER=rapidtide
RUN useradd \
--create-home \
--shell /bin/bash \
--groups users \
--home /home/$USER \
$USER
RUN chown -R $USER /src/$USER
WORKDIR /home/$USER
ENV HOME="/home/rapidtide"

RUN /opt/miniforge3/bin/mamba init
RUN echo "mamba activate science" >> /home/rapidtide/.bashrc
RUN echo "/opt/miniforge3/bin/mamba activate science" >> /home/rapidtide/.bashrc

# switch to the rapidtide user
USER rapidtide

# set up variable for non-interactive shell
ENV PATH=/opt/miniforge3/envs/science/bin:/opt/miniforge3/condabin:.:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

ENV IS_DOCKER_8395080871=1
ENV IN_DOCKER_CONTAINER=1

WORKDIR /tmp/
ENTRYPOINT ["/cloud/mount-and-run"]
Expand Down
2 changes: 1 addition & 1 deletion rapidtide/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ def version():
"""
try:
dummy = os.environ["IS_DOCKER_8395080871"]
dummy = os.environ["IN_DOCKER_CONTAINER"]
except KeyError:
isdocker = False
else:
Expand Down
2 changes: 1 addition & 1 deletion rapidtide/workflows/happy.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def happy_main(argparsingfunc):

# if we are running in a Docker container, make sure we enforce memory limits properly
try:
testval = os.environ["IS_DOCKER_8395080871"]
testval = os.environ["IN_DOCKER_CONTAINER"]
except KeyError:
args.runningindocker = False
else:
Expand Down
28 changes: 27 additions & 1 deletion rapidtide/workflows/rapidtide.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def rapidtide_main(argparsingfunc):
print("turning on garbage collection")

# if we are running in a Docker container, make sure we enforce memory limits properly
if "IS_DOCKER_8395080871" in os.environ:
if "IN_DOCKER_CONTAINER" in os.environ:
optiondict["runningindocker"] = True
optiondict["dockermemfree"], optiondict["dockermemswap"] = tide_util.findavailablemem()
if optiondict["dockermemfix"]:
Expand Down Expand Up @@ -3339,6 +3339,28 @@ def rapidtide_main(argparsingfunc):
debug=optiondict["focaldebug"],
)

if optiondict["glmderivs"] == 1:
# special case - calculate the ratio of derivative to raw regressor
glmderivratio = np.nan_to_num(fitcoeff[:, 1] / fitcoeff[:, 0])
ratiolist = np.linspace(-10.0, 10.0, 21, endpoint=True)
"""outtcs = np.zeros((len(ratiolist), regressorset.shape[]), dtype=rt_floattype)
colnames = []
for ratioidx in range(outtcs.shape[0]):
outtcs[ratioidx, :] = tide_math.stdnormalize(
regressorset[0, :] + ratiolist[ratioidx] * regressorset[1, :]
)
colnames.append(str(ratiolist[ratioidx]))
tide_io.writebidstsv(
f"{outputname}_desc-glmratio_timeseries",
outtcs,
oversampfreq,
columns=["filteredRMS", "linearfit"],
extraheaderinfo={
"Description": "Filtered RMS amplitude of the probe regressor, and a linear fit"
},
append=False,
)"""

# calculate the final bandlimited mean normalized variance
finalvariance = tide_math.imagevariance(filtereddata, theprefilter, 1.0 / fmritr)
divlocs = np.where(finalvariance > 0.0)
Expand Down Expand Up @@ -3502,6 +3524,10 @@ def rapidtide_main(argparsingfunc):
(coherencepeakval, "coherencepeakval", "map", None, "Coherence peak value"),
(coherencepeakfreq, "coherencepeakfreq", "map", None, "Coherence peak frequency"),
]
if optiondict["glmderivs"] == 1:
savelist += [
(glmderivratio, "glmderivratio", "map", None, "GLM derivative ratio"),
]
tide_io.savemaplist(
outputname,
savelist,
Expand Down

0 comments on commit 4d42b8a

Please sign in to comment.