From 9b385c7ec66bfd8e72ec6f6f0168d6ce7ea0f36b Mon Sep 17 00:00:00 2001 From: Blaise deB Frederick Date: Fri, 15 Nov 2024 11:12:51 -0500 Subject: [PATCH 1/2] Update rapidtide.py --- rapidtide/workflows/rapidtide.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/rapidtide/workflows/rapidtide.py b/rapidtide/workflows/rapidtide.py index 3e954a46..98e2301b 100755 --- a/rapidtide/workflows/rapidtide.py +++ b/rapidtide/workflows/rapidtide.py @@ -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) @@ -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, From 80b196b3224e3ceb6859cabf7872696960b0fe42 Mon Sep 17 00:00:00 2001 From: Blaise deB Frederick Date: Fri, 15 Nov 2024 15:21:17 -0500 Subject: [PATCH 2/2] Use new IN_DOCKER_CONTAINER variable --- Dockerfile | 19 ++++++++++++++----- rapidtide/util.py | 2 +- rapidtide/workflows/happy.py | 2 +- rapidtide/workflows/rapidtide.py | 2 +- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index d38c1f26..404b8fa2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/rapidtide/util.py b/rapidtide/util.py index de6d8bf7..3eb25f92 100644 --- a/rapidtide/util.py +++ b/rapidtide/util.py @@ -453,7 +453,7 @@ def version(): """ try: - dummy = os.environ["IS_DOCKER_8395080871"] + dummy = os.environ["IN_DOCKER_CONTAINER"] except KeyError: isdocker = False else: diff --git a/rapidtide/workflows/happy.py b/rapidtide/workflows/happy.py index 24f21a99..acbd998e 100644 --- a/rapidtide/workflows/happy.py +++ b/rapidtide/workflows/happy.py @@ -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: diff --git a/rapidtide/workflows/rapidtide.py b/rapidtide/workflows/rapidtide.py index 98e2301b..94397a10 100755 --- a/rapidtide/workflows/rapidtide.py +++ b/rapidtide/workflows/rapidtide.py @@ -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"]: