generated from datalad/datalad-extension-template
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Update examples #62
Open
m-wierzba
wants to merge
2
commits into
datalad:update-examples
Choose a base branch
from
m-wierzba:update-examples
base: update-examples
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Update examples #62
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
# Use case: resample a BOLD image onto a target space | ||
|
||
This example demonstrates how to run a simple Python [script](https://hub.datalad.org/mslw/fmriprep-resampling) to reproduce fMRIPrep's preprocessed BOLD image (projected onto a target space) from the raw image, ancillary fMRIPrep derivatives, and related metadata. All dependencies for the script are provided by an fMRIPrep singularity container. The singularity container used in this example is `bids-fmriprep--24.1.0` and comes from the [ReproNim containers collection](https://github.com/ReproNim/containers). | ||
|
||
The example comprises the following files: | ||
- `fmriprep-resample` template | ||
- `input.txt` input specification | ||
- `output.txt` output specification | ||
- `parameter.txt` parameters | ||
|
||
## Requirements | ||
|
||
This example requires Singularity. | ||
|
||
Please note, that there is no need to install fMRIPrep. The singularity container will be automatically retrieved from the ReproNim containers collection. | ||
|
||
## How to install | ||
|
||
Install `datalad-remake` extension, as described [here](https://github.com/datalad/datalad-remake/tree/main?tab=readme-ov-file#installation). | ||
|
||
## How to use | ||
|
||
It is assumed that you have a local copy of the `datalad-remake` project in your `$HOME` directory. If this not the case, adjust the path below: | ||
|
||
``` | ||
EXAMPLE=$HOME/datalad-remake/examples/fmriprep-resample | ||
``` | ||
|
||
### Clone example dataset | ||
|
||
To run the example, you'll need a raw BIDS dataset that has been minimally preprocessed with fMRIPrep. For a complete list of data dependencies, please refer to [this](https://github.com/datalad/datalad-remake/blob/main/examples/fmriprep-resample/input.txt) specification. | ||
|
||
For convenience, a ready-made dataset containing all inputs required for running the example can be obtained like so: | ||
|
||
```bash | ||
> cd $HOME | ||
> datalad clone https://hub.datalad.org/example my-project | ||
> cd my-project | ||
> datalad get -n data/ds001734 | ||
> datalad get -n derivatives/ds001734 | ||
``` | ||
|
||
The dataset is organized in a modular way. It contains raw BIDS data (`data/ds001734`), as well as fMRIPrep derivative data (`derivatives/ds001734`). Also, it includes the `resample.py` script, as well as the software container that will be needed for running the script (`code/containers`). | ||
|
||
The resulting dataset structure is as follows: | ||
|
||
``` | ||
my-project | ||
├── code | ||
│ ├── containers | ||
│ ├── make | ||
│ └── resample.py | ||
├── data | ||
│ └── ds001734 | ||
└── derivatives | ||
└── ds001734 | ||
``` | ||
|
||
### Configure (or enable) special remote | ||
|
||
Configure the dataset in which you want to collect the results of the (re)computation, in this case `derivatives/ds001734` subdataset. | ||
|
||
```bash | ||
> cd $HOME/my-project/derivatives/ds001734 | ||
``` | ||
|
||
If you're working with the ready-made example dataset, you are good to go. The `datalad-remake` special remote is already enabled. You can verify that by running: | ||
|
||
```bash | ||
> datalad siblings | ||
``` | ||
|
||
If you're working with your own dataset, make sure to configure a `datalad-remake` special remote: | ||
|
||
```bash | ||
> git annex initremote datalad-remake type=external externaltype=datalad-remake \ | ||
encryption=none allow-untrusted-execution=true autoenable=true | ||
``` | ||
Comment on lines
+73
to
+78
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. remove this section, manual datalad-remake start is not necessary anymore |
||
|
||
### Add template | ||
|
||
Place the `fmriprep-resample` template in the `.datalad/make/methods` of the root dataset: | ||
|
||
```bash | ||
> cd $HOME/my-project | ||
> cp $EXAMPLE/fmriprep-resample .datalad/make/methods/fmriprep-resample | ||
> datalad save -m "Add a make method" | ||
``` | ||
|
||
Place the `input.txt`, `output.txt` and `parameter.txt` files in the root dataset. These files do not have to be tracked in git history, so no `datalad save` is required at this point. | ||
|
||
```bash | ||
> mkdir -p code/make/fmriprep-resample | ||
> cp $EXAMPLE/*.txt ./code/make/fmriprep-resample/ | ||
``` | ||
|
||
### Execute (re)computation | ||
|
||
To test the example, run: | ||
|
||
```bash | ||
> cd $HOME/my-project | ||
> datalad make \ | ||
-I code/make/fmriprep-resample/input.txt \ | ||
-O code/make/fmriprep-resample/output.txt \ | ||
-P code/make/fmriprep-resample/parameter.txt \ | ||
--allow-untrusted-execution fmriprep-resample | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# This example template runs a Python script to reproduce fMRIPrep's | ||
# preprocessed BOLD image (projected onto a target space) from the raw image, | ||
# ancillary fMRIPrep derivatives, and related metadata. All dependencies for | ||
# the script are provided by an fMRIPrep singularity container. | ||
# | ||
# The template takes the following inputs: | ||
# - container: the path to fMRIPrep singularity container image | ||
# - target_file: resampled file (fMRIPrep derivative) to reproduce | ||
# - raw_dataset: raw BIDS dataset location | ||
# - out_dir: base output path | ||
|
||
parameters = ['container', 'target_file', 'raw_dataset', 'out_dir'] | ||
|
||
# Note: `{root_directory}` resolves to the directory of the dataset in which the | ||
# computation was started with `datalad make`. | ||
|
||
command = [ | ||
'singularity', | ||
'exec', '{container}', | ||
'python', 'code/resample.py', | ||
'{target_file}', | ||
'{root_directory}/{raw_dataset}', | ||
'{root_directory}/{out_dir}' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Paths are relative to the dataset in which `datalad make` was executed | ||
derivatives/ds001734/dataset_description.json | ||
derivatives/ds001734/sub-001/func/sub-001_task-MGT_run-01_space-MNI152NLin2009cAsym_desc-preproc_bold.json | ||
derivatives/ds001734/sub-001/fmap/sub-001_fmapid-auto00000_desc-preproc_fieldmap.json | ||
derivatives/ds001734/sub-001/func/sub-001_task-MGT_run-01_desc-confounds_timeseries.tsv | ||
data/ds001734/task-MGT_bold.json | ||
data/ds001734/sub-001/func/sub-001_task-MGT_run-01_bold.nii.gz | ||
derivatives/ds001734/sub-001/func/sub-001_task-MGT_run-01_from-orig_to-boldref_mode-image_desc-hmc_xfm.txt | ||
derivatives/ds001734/sub-001/func/sub-001_task-MGT_run-01_from-boldref_to-auto00000_mode-image_xfm.txt | ||
derivatives/ds001734/sub-001/func/sub-001_task-MGT_run-01_from-boldref_to-T1w_mode-image_desc-coreg_xfm.txt | ||
derivatives/ds001734/sub-001/anat/sub-001_from-T1w_to-MNI152NLin2009cAsym_mode-image_xfm.h5 | ||
derivatives/ds001734/sub-001/func/sub-001_task-MGT_run-01_space-MNI152NLin2009cAsym_boldref.nii.gz | ||
derivatives/ds001734/sub-001/func/sub-001_task-MGT_run-01_space-MNI152NLin2009cAsym_desc-brain_mask.nii.gz | ||
derivatives/ds001734/sub-001/func/sub-001_task-MGT_run-01_desc-hmc_boldref.nii.gz | ||
derivatives/ds001734/sub-001/fmap/sub-001_fmapid-auto00000_desc-magnitude_fieldmap.nii.gz | ||
derivatives/ds001734/sub-001/fmap/sub-001_fmapid-auto00000_desc-coeff_fieldmap.nii.gz | ||
code/containers/images/bids/bids-fmriprep--24.1.0.sing | ||
code/resample.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Paths are relative to the dataset in which `datalad make` was executed | ||
derivatives/ds001734/sub-001/func/sub-001_task-MGT_run-01_space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
container=code/containers/images/bids/bids-fmriprep--24.1.0.sing | ||
target_file=derivatives/ds001734/sub-001/func/sub-001_task-MGT_run-01_space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz | ||
raw_dataset=data/ds001734 | ||
out_dir=derivatives/ds001734 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,7 +66,8 @@ Configure the dataset in which you want to collect the results of the (re)comput | |
Add a `datalad-remake` special remote: | ||
|
||
```bash | ||
> git annex initremote datalad-remake type=external externaltype=datalad-remake encryption=none allow-untrusted-execution=true | ||
> git annex initremote datalad-remake type=external externaltype=datalad-remake \ | ||
encryption=none allow-untrusted-execution=true autoenable=true | ||
``` | ||
Comment on lines
66
to
71
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 is no longer required (see above) |
||
|
||
### Add template | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is not necessary anymore because
datalad make
will automatically start remotes