Rapidtide

Rapidtide is a set of tools for analyzing physiological signals in fMRI and fNIRS data, including signals associated with blood flow and the heartbeat. It can be used to determine how these signals vary across the brain and how long they take to reach different regions. It can also help remove physiological noise from data. The package includes happy, which focuses on cardiac signals.

References:

Documentation
Important Notes

Interactive job
Interactive jobs should be used for debugging, graphics, or applications that cannot be run as batch jobs.

Allocate an interactive session and run the program. Sample session:

[user@biowulf]$ sinteractive
[user@cn3335 ~]$ module load rapidtide
[+] Loading rapidtide  3.2.0  on cn3335 
[+] Loading singularity  4.3.7  on cn3335

[user@cn3335 ~]$ rapidtide --help
usage: rapidtide [-h] [--denoising | --delaymapping | --CVR | --globalpreselect] [--venousrefine | --nirs]
                 [--brainmask MASK[:VALSPEC]] [--graymattermask MASK[:VALSPEC]] [--whitemattermask MASK[:VALSPEC]]
                 [--csfmask MASK[:VALSPEC]] [--datatstep TSTEP | --datafreq FREQ] [--noantialias] [--invert]
                 [--interptype {univariate,cubic,quadratic}] [--offsettime OFFSETTIME] [--autosync]
[...]

[user@cn3335 ~]$ happy --help
usage: happy [-h] [--cardcalconly] [--skipdlfilter] [--usesuperdangerousworkaround] [--slicetimesareinseconds]
             [--model MODELNAME] [--mklthreads NTHREADS] [--nprocs NPROCS] [--numskip SKIP] [--motskip SKIP]
             [--motionfile MOTFILE] [--motionhp HPFREQ] [--motionlp LPFREQ] [--nomotorthogonalize] [--nomotderiv]
             [--motfiltorder N] [--discardmotionfiltered] [--gmsfilt] [--estweights WEIGHTSNAME] [--minhr MINHR]
             [--maxhr MAXHR] [--minhrfilt MINHR] [--maxhrfilt MAXHR] [--hilbertcomponents NCOMPS]
[...]

Batch job
Most jobs should be run as batch jobs.

Create a batch input file (e.g. rapidtide.sh). For example (using test data below):

#!/bin/bash
#SBATCH --job-name=rapidtide
#SBATCH --cpus-per-task=4
#SBATCH --mem=4G
#SBATCH --time=01:00:00
#SBATCH --output=rapidtide-%j.out

module load rapidtide/3.2.0

mkdir -pv /data/${USER}/RAPIDTIDE-TEST
cd /data/${USER}/RAPIDTIDE-TEST

wget -O testdatabundle.tgz  \
  https://raw.githubusercontent.com/bbfrederick/rapidtide/v3.2.0/rapidtide/data/examples/testdatabundle.tgz

tar -xOzf testdatabundle.tgz --no-anchored sub-RAPIDTIDETEST.nii.gz > sub-RAPIDTIDETEST.nii.gz

mkdir -p output

rapidtide sub-RAPIDTIDETEST.nii.gz \
          output/test \
          --filterband lfo \
          --searchrange -15 15 \
          --passes 3  \
          --nprocs 4

Submit this job using the Slurm sbatch command.

sbatch rapidtide.sh
Swarm of Jobs
A swarm of jobs is an easy way to submit a set of independent commands requiring identical resources.

Create a swarmfile (e.g. rapidtide.swarm). For example:

#SWARM -g 4
#SWARM -t 4
#SWARM --module rapidtide/3.2.0

rapidtide sub-RAPIDTIDETEST1.nii.gz test1 --filterband lfo --searchrange -15 15 --passes 3 --nprocs 4
rapidtide sub-RAPIDTIDETEST2.nii.gz test2 --filterband lfo --searchrange -15 15 --passes 3 --nprocs 4
rapidtide sub-RAPIDTIDETEST3.nii.gz test3 --filterband lfo --searchrange -15 15 --passes 3 --nprocs 4

Submit this job using the swarm command.

swarm rapidtide.swarm
where
-g # Number of Gigabytes of memory required for each process (1 line in the swarm command file)
-t # Number of threads/CPUs required for each process (1 line in the swarm command file).
--module rapidtide Loads the rapidtide module for each subjob in the swarm