Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
version: 2
updates:
- package-ecosystem: "github-actions"
- package-ecosystem: github-actions
# Workflow files stored in the default location of `.github/workflows`.
# (You don't need to specify `/.github/workflows` for `directory`.
# You can use `directory: "/"`.)
directory: "/"
directory: /
# Run on first of each month
schedule:
interval: "monthly"
interval: monthly
# Group to submit a single PR if possible
groups:
github-actions:
patterns:
- "*"
patterns: ['*']
6 changes: 4 additions & 2 deletions docs/getting_started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ supported**. We do not have a Docker arm64 container yet._

### Notes
* Inputs to SCATTR should be a BIDS dataset, including processed Freesurfer
and DWI derivatives (which can be stored separately).
and DWI derivatives. If any BIDS files are stored separately, you can point to these using the
relevant `--path-{component}` CLI option. The Freesurfer folder is specified with a separate
CLI option `--freesurfer-dir`(which can be stored separately).

## Docker on Windows / Mac (Intel) / Linux

Expand Down Expand Up @@ -49,4 +51,4 @@ Instructions can be found in the [Contributing](https://scattr.readthedocs.io/en
* Flexibility to modify code

### Cons
* Only compatible on systems with Singularity for external dependencies
* Only compatible on systems with Singularity for external dependencies
3 changes: 0 additions & 3 deletions docs/outputs/output_files.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,3 @@ Workflow steps that write logs to file are stored in the hidden `.logs`
subfolder, with the file names based on the tools used (e.g. `mrtrix`) and rule
wildcards (e.g. `subject`).

If the app is run in workflow mode (`--workflow-mode` / `-W`), which enables
direct use of the Snakemake CLI to run scattr, output folders (e.g. `work`) will
be placed in a `results` folder.
4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
docutils<0.18
sphinx-argparse
sphinx-argparse<0.5.0
sphinx_rtd_theme
sphinxcontrib-asciinema
myst-parser
myst-parser
2 changes: 1 addition & 1 deletion docs/usage/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ the dataset, so we suggest using the
your dataset has no errors.

If you passed Freesurfer or diffusion derivative locations (`--freesurfer-dir`
or `--dwi-dir`), you may get get this message as the files are a different
or `--path-dwi`), you may get get this message as the files are a different
location than in the input directory provided.

### 2. What if I want to use merge two different atlases?
Expand Down
16 changes: 12 additions & 4 deletions docs/usage/useful_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,19 @@ Similarly, subjects can be excluded from processing using the
## Alternate Freesurfer / derived-diffusion data locations

By default, SCATTR attempts to locate Freesurfer and derived diffusion data
locations. Users can overwrite these options, by passing along the actual
location of each using either `--freesurfer_dir` or `--dwi_dir`, respectively.
locations. Users can overwrite the Freesurfer location by passing `--freesurfer_dir`,
e.g.:

```
--freesurfer_dir /path/to/fs_dir --dwi_dir /path/to/dwi_dir
--freesurfer_dir /path/to/fs_dir
```

The paths to any of the BIDS files (T1w, dwi, dwi mask) can always be customized
using the `--path-T1w`, `--path-dwi`, or `--path-mask` options. Note, you must
include generic wildcards in any path you specify, e.g.:

```
--path-T1w /mydata/project1/sub-{subject}/T1.nii.gz`
```

## Pre-generated average response function
Expand Down Expand Up @@ -121,4 +129,4 @@ filter out extra files, but for now, if your dataset has these issues, you will
need to rename or remove extraneous files.

More example of possible BIDS-compliant datasets can be found in
`scattr/test/data`.
`scattr/test/data`.
10 changes: 8 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,20 @@ python ./scattr/run.py ./test/data/bids test/data/derivatives/ participant \
[tool.poe.tasks.test_dwi]
shell = """
python ./scattr/run.py ./test/data/bids_nodwi test/data/derivatives/ \
participant --dwi_dir ./test/data/derivatives/prepdwi \
participant --path-dwi \
./test/data/derivatives/prepdwi/sub-{subject}/dwi/sub-{subject}_space-T1w_desc-preproc_dwi.nii.gz \
--path-mask \
./test/data/derivatives/prepdwi/sub-{subject}/dwi/sub-{subject}_space-T1w_desc-preproc_mask.nii.gz \
--fs-license ./test/.fs_license -np --force-output
"""

[tool.poe.tasks.test_snakedwi]
shell = """
python ./scattr/run.py ./test/data/bids_nodwi test/data/derivatives/ \
participant --dwi_dir ./test/data/derivatives/snakedwi \
participant --path-dwi \
./test/data/derivatives/snakedwi/sub-{subject}/dwi/sub-{subject}_space-T1w_desc-eddy_res-orig_dwi.nii.gz \
--path-dwi-mask \
./test/data/derivatives/snakedwi/sub-{subject}/dwi/sub-{subject}_space-T1w_desc-eddy_res-orig_mask.nii.gz \
--fs-license ./test/.fs_license -np --force-output
"""

Expand Down
14 changes: 0 additions & 14 deletions scattr/config/snakebids.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ pybids_inputs:
extension: ".nii.gz"
datatype: "anat"
desc: "brain" # Require a skull-stripped brain
part: ["mag", false]
wildcards:
- subject
- session
- run
pybids_inputs_dwi:
dwi:
filters:
suffix: "dwi"
Expand Down Expand Up @@ -102,18 +100,6 @@ parse_args:
nargs: "?"
type: Path

--dwi_dir:
help: "The path to the directory containing pre-processed dwi data
transformed to subject T1w space. If not provided, workflow assumes
this data exists in <bids_dir>/<subject>/dwi."
nargs: "?"
type: Path

--pybidsdb_dwi_dir:
help: "The path to the pybids database associated with provided dwi_dir"
nargs: "?"
type: Path

--responsemean_dir:
help: "The path to the directory containing average response functions. If
not provided, one will be computed from the subjects in the input
Expand Down
20 changes: 4 additions & 16 deletions scattr/workflow/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ configfile: "config/snakebids.yml"


# writes inputs_config.yml and updates config dict
inputs_t1w = generate_inputs(
inputs = generate_inputs(
bids_dir=config["bids_dir"],
pybids_inputs=config["pybids_inputs"],
pybids_config=["bids", "derivatives"],
Expand All @@ -22,18 +22,6 @@ inputs_t1w = generate_inputs(
participant_label=config["participant_label"],
exclude_participant_label=config["exclude_participant_label"],
)
inputs_dwi = generate_inputs(
bids_dir=config["dwi_dir"] if config["dwi_dir"] else config["bids_dir"],
pybids_inputs=config["pybids_inputs_dwi"],
pybids_config=["bids", "derivatives"],
pybidsdb_dir=config.get("pybidsdb_dwi_dir")
if config["dwi_dir"]
else config.get("pybidsdb_dir"),
pybidsdb_reset=config.get("pybidsdb_reset"),
derivatives=config["derivatives"],
participant_label=config["participant_label"],
exclude_participant_label=config["exclude_participant_label"],
)


# this adds constraints to the bids naming
Expand All @@ -56,7 +44,7 @@ if config.get("labelmerge_base_dir") or config.get("labelmerge_overlay_dir"):
"""
)

if len(inputs_dwi.sessions) > 1 and not config.get("responsemean_ses"):
if len(inputs.sessions) > 1 and not config.get("responsemean_ses"):
print(
"""
WARNING: Multiple sessions detected - average response function will be
Expand All @@ -75,10 +63,10 @@ include: "rules/qc.smk"

rule all:
input:
tck_files=inputs_t1w["T1w"].expand(
tck_files=inputs["T1w"].expand(
rules.filtered_tck2connectome.output.sl_assignment
),
dti_files=inputs_t1w["T1w"].expand(rules.dwi2tensor.output.dti),
dti_files=inputs["T1w"].expand(rules.dwi2tensor.output.dti),
qc_files=rules.gather_qc.input,
params:
mrtrix_dir=mrtrix_dir,
Expand Down
16 changes: 6 additions & 10 deletions scattr/workflow/rules/freesurfer.smk
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ bids_fs_out = partial(
bids,
root=freesurfer_dir,
datatype="anat",
**inputs_t1w.subj_wildcards,
**inputs.subj_wildcards,
)

bids_log = partial(
bids,
root=log_dir,
**inputs_t1w.subj_wildcards,
**inputs.subj_wildcards,
)

"""Freesurfer references (with additional in rules as necessary)
Expand Down Expand Up @@ -73,12 +73,10 @@ rule thalamic_segmentation:
freesurfer_dir=freesurfer_dir,
params:
fs_license=fs_license,
subj_dir=str(Path(bids(**inputs_t1w.subj_wildcards)).parent),
subj_dir=str(Path(bids(**inputs.subj_wildcards)).parent),
output:
thal_seg=str(
Path(
bids(root=freesurfer_dir, **inputs_t1w.subj_wildcards)
).parent
Path(bids(root=freesurfer_dir, **inputs.subj_wildcards)).parent
/ "mri"
/ "ThalamicNuclei.v12.T1.mgz"
),
Expand Down Expand Up @@ -115,9 +113,7 @@ rule mgz2nii:
if not config.get("skip_thal_seg")
else [],
aparcaseg=str(
Path(
bids(root=freesurfer_dir, **inputs_t1w.subj_wildcards)
).parent
Path(bids(root=freesurfer_dir, **inputs.subj_wildcards)).parent
/ "mri"
/ "aparc+aseg.mgz"
),
Expand Down Expand Up @@ -162,7 +158,7 @@ rule fs_xfm_to_native:
input:
thal=rules.mgz2nii.output.thal,
aparcaseg=rules.mgz2nii.output.aparcaseg,
ref=lambda wildcards: inputs_t1w["T1w"].filter(**wildcards).expand()[0],
ref=lambda wildcards: inputs["T1w"].filter(**wildcards).expand()[0],
output:
thal=bids_fs_out(
space="T1w",
Expand Down
10 changes: 5 additions & 5 deletions scattr/workflow/rules/mrtpipelines.smk
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,35 @@ bids_dti_out = partial(
root=mrtrix_dir,
datatype="dti",
model="dti",
**inputs_dwi.subj_wildcards,
**inputs.subj_wildcards,
)

bids_tractography_out = partial(
bids,
root=mrtrix_dir,
datatype="tractography",
**inputs_dwi.subj_wildcards,
**inputs.subj_wildcards,
)

bids_anat_out = partial(
bids,
root=mrtrix_dir,
datatype="anat",
**inputs_t1w.subj_wildcards,
**inputs.subj_wildcards,
)

bids_labelmerge = partial(
bids,
root=str(Path(labelmerge_dir) / "combined")
if not config.get("skip_labelmerge")
else config.get("labelmerge_base_dir") or zona_dir,
**inputs_t1w.subj_wildcards,
**inputs.subj_wildcards,
)

bids_log = partial(
bids,
root=log_dir,
**inputs_dwi.subj_wildcards,
**inputs.subj_wildcards,
)

"""Mrtrix3 reference (additional citations are included per rule as necessary):
Expand Down
Loading