Skip to content
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

Adds in Tutorial #7

Merged
merged 10 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ test.log
/docker-tests
~*
/docs/source/_static/images/logo-square.png
/src/australianimagingservice_community/_version.py
/src/**/_version.py
*.venv
.mypy_cache
.build*
.ipynb_checkpoints
10 changes: 2 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
arcana >=0.10.11
arcana-xnat >= 0.3.6
fileformats >= 0.8.6
fileformats-extras >= 0.2.1
fileformats-datascience >= 0.1.0
fileformats-datascience-extras >= 0.1.1
fileformats-medimage >= 0.4.4
fileformats-medimage-extras >= 0.1.5
pydra2app-xnat >=0.51

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
arcana_spec_version: 1.0 # the version of the specification format used for this file
title: 'Preprocess T1-weighted MRI' # Short name for the pipeline referenced in the UI
title: "Preprocess T1-weighted MRI" # Short name for the pipeline referenced in the UI
schema_version: 1.0 # the version of the specification format used for this file
version:
# The version of Ubuntu's zip we are using
package: "1.0"
Expand All @@ -24,18 +24,19 @@ packages:
neurodocker:
mrtrix3: 3.0.2
command:
task: australianimagingservice.community.au.edu.sydney.sydneyimaging.t1_preproc:t1_preproc # Use the generic "shell-cmd" task
row_frequency: session # the pipeline is desgined to run on imaging "sessions" as opposed to "subjects" or "projects"
inputs: # List the inputs that are presented to end-user in UI
task: australianimagingservice.community.au.edu.sydney.sydneyimaging.t1_preproc:t1_preproc # Use the generic "shell-cmd" task
row_frequency: session # the pipeline is desgined to run on imaging "sessions" as opposed to "subjects" or "projects"
inputs: # List the inputs that are presented to end-user in UI
example_input:
datatype: medimage/dicom-series # MIME-type or "MIME-like" format
help: "Example Input" # description of field presented in UI
outputs: # List the outputs generated by the pipeline
datatype: medimage/dicom-series # MIME-type or "MIME-like" format
help: "Example Input" # description of field presented in UI
outputs: # List the outputs generated by the pipeline
example_output:
datatype: medimage/nifti-gz-x # MIME-type or "MIME-like" format
help: Example Output # description of field presented in UI
parameters: # Parameters exposed to user to UI
datatype: medimage/nifti-gz-x # MIME-type or "MIME-like" format
help: Example Output # description of field presented in UI
parameters: # Parameters exposed to user to UI
example_param:
datatype: field/integer # Format of the field
help: an example parameter # description of field presented in UI
default: 99 # Default value, filled in on the UI
datatype: field/integer # Format of the field
help: an example parameter # description of field presented in UI
default: 99 # Default value, filled in on the UI

46 changes: 22 additions & 24 deletions specs/australian-imaging-service-community/examples/bet.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
arcana_spec_version: 1.0 # the version of the specification format used for this file
title: 'Example BET pipeline' # Short name for the pipeline referenced in the UI
schema_version: 1.0 # the version of the specification format used for this file
title: "Example BET pipeline" # Short name for the pipeline referenced in the UI
version:
# Define a version for the pipeline in combination of the underlying package version (e.g. FSL)
# and the "build" of the pipeline
Expand All @@ -8,8 +8,8 @@ version:
base_image:
# Chose a NeuroDesk FSL container as the base
name: vnmd/fsl_6.0.6.4
package_manager: apt # It is not obvious from the base image what the package manager is
tag: '20230618'
package_manager: apt # It is not obvious from the base image what the package manager is
tag: "20230618"
packages:
# Install dependencies for DICOM->NIfTI conversion
pip:
Expand All @@ -22,29 +22,27 @@ authors:
- name: Thomas G. Close
email: [email protected]
docs:
info_url: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki # Link to external documentation for underlying tool
description: | # Description of tool for auto-docs
info_url: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki # Link to external documentation for underlying tool
description: | # Description of tool for auto-docs
An example wrapping BET in a XNAT pipeline
command:
task: arcana.common:shell_cmd # Use the generic "shell-cmd" task
row_frequency: session # the pipeline is desgined to run on imaging "sessions" as opposed to "subjects" or "projects"
inputs: # List the inputs that are presented to end-user in UI
T1w:
datatype: medimage/nifti-gz # MIME-type or "MIME-like" format
help: "T1-weighted anatomical scan" # description of field presented in UI
configuration: # Additional configuration parameters that are passed to the arcana.common:shell_cmd task in the "inputs" dict
position: -2 # Position of field when printed to command line call. Negative numbers are indexed from the end backwards
argstr: '' # prefix for field when printed to command line
column_defaults:
datatype: medimage/dicom-series # the default
outputs: # List the outputs generated by the pipeline
task: common:shell # Use the generic "shell-cmd" task
row_frequency: session # the pipeline is desgined to run on imaging "sessions" as opposed to "subjects" or "projects"
inputs: # List the inputs that are presented to end-user in UI
t1w:
datatype: medimage/nifti-gz # MIME-type or "MIME-like" format
help: "T1-weighted anatomical scan" # description of field presented in UI
configuration: # Additional configuration parameters that are passed to the pydra2app.common:shell task in the "inputs" dict
position: -2 # Position of field when printed to command line call. Negative numbers are indexed from the end backwards
argstr: "" # prefix for field when printed to command line
outputs: # List the outputs generated by the pipeline
brain:
datatype: medimage/nifti-gz # MIME-type or "MIME-like" format
help: Brain-extracted data # description of field presented in UI
configuration: # Additional configuration parameters that are passed to the arcana.common:shell_cmd task in the "outputs" dict
position: -1 # Position of field when printed to command line call. Negative numbers are indexed from the end backwards
argstr: '' # prefix for field when printed to command line
datatype: medimage/nifti-gz # MIME-type or "MIME-like" format
help: Brain-extracted data # description of field presented in UI
configuration: # Additional configuration parameters that are passed to the pydra2app.common:shell task in the "outputs" dict
position: -1 # Position of field when printed to command line call. Negative numbers are indexed from the end backwards
argstr: "" # prefix for field when printed to command line
parameters: {}
configuration: # Additional args passed to arcana.common:shell_cmd
configuration: # Additional args passed to pydra2app.common:shell
name: bet
executable: bet
69 changes: 45 additions & 24 deletions specs/australian-imaging-service-community/examples/zip.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
arcana_spec_version: 1.0 # the version of the specification format used for this file
title: 'Zip up a directory' # Short name for the pipeline referenced in the UI
# The version of the specification format used for this file
schema_version: 1.0
# Short name for the pipeline referenced in the UI
title: "Zips up a file or directory"
version:
# The version of Ubuntu's zip we are using
package: "3.0"
Expand All @@ -21,34 +23,53 @@ docs:
packages:
# Install the zip command in the Ubuntu image
system:
- zip
- zip
command:
task: arcana.common:shell_cmd # Use the generic "shell-cmd" task
row_frequency: session # the pipeline is desgined to run on imaging "sessions" as opposed to "subjects" or "projects"
inputs: # List the inputs that are presented to end-user in UI
# Use the generic "shell-command" task
task: common:shell
# the pipeline is desgined to run on imaging "sessions" as opposed to "subjects" or "projects"
row_frequency: session
# List the inputs that are presented to end-user in UI
inputs:
to_zip:
datatype: generic/fs-object # MIME-type or "MIME-like" format
help: "Input file-system object to zip" # description of field presented in UI
configuration: # Additional configuration args that are passed to the arcana.common:shell_cmd task as part of the "inputs" dict
argstr: '' # Position of field when printed to command line call. Negative numbers are indexed from the end backwards
position: -1 # prefix for field when printed to command line
outputs: # List the outputs generated by the pipeline
# MIME-type or "MIME-like" format, generic/fs-object corresponds a file or directory
datatype: generic/fs-object
# description of field presented in UI
help: "Input file-system object to zip"
# Additional config args that are passed to the shell task as part of the "inputs" dict
configuration:
# Position of field on command line call. Negative numbers are indexed backwards from the end
argstr: ""
# prefix for field when printed to command line
position: -1
# List the outputs generated by the pipeline
outputs:
zipped:
datatype: application/zip # MIME-type or "MIME-like" format
help: Zipped FS Object # description of field presented in UI
# MIME-type or "MIME-like" format
datatype: application/zip
# description of field presented in UI
help: Zipped file-system Object
# Additional config args that are passed to the shell task as part of the "outputs" dict
configuration:
argstr: '' # Position of field when printed to command line call. Negative numbers are indexed from the end backwards
position: -2 # prefix for field when printed to command line
parameters: # Parameters exposed to user to UI
# Position of field on command line call. Negative numbers are indexed backwards from the end
argstr: ""
# prefix for field when printed to command line
position: -2
# Parameters exposed to user to UI
parameters:
compression:
datatype: field/integer # Format of the field
help: the level of compression applied # description of field presented in UI
default: 5 # Default value, filled in on the UI
configuration: # Additional configuration parameter args that are passed to the arcana.common:shell_cmd task in the "parameters" dict
# Format of the field
datatype: field/integer
# description of field presented in UI
help: the level of compression applied
# Default value, filled in on the UI
default: 5
# Additional config args that are passed to the shell task in the "parameters" dict
configuration:
# string template for field when printed to command line. "{field-name}" are
# replaced by the value provided to the field name
argstr: -{compression}
configuration: # Additional args passed to arcana.common:shell_cmd
name: zip_dir
# Additional args passed to shell
configuration:
# the command to run
executable: zip

32 changes: 16 additions & 16 deletions tests/test_bet.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

from pathlib import Path
import tempfile
from arcana.common import Clinical
from frametree.common import Clinical
from fileformats.medimage import NiftiGz
from arcana.common import DirTree
from frametree.common import DirTree
from arcana.testing.data.blueprint import (
TestDatasetBlueprint, FileSetEntryBlueprint as FileBP
TestDatasetBlueprint,
FileSetEntryBlueprint as FileBP,
)
from arcana.core.deploy.command import ContainerCommand
from pydra2app.core.command import ContainerCommand
from medimages4tests.mri.neuro.t1w import get_image


Expand All @@ -19,21 +19,21 @@
NiftiGz(get_image()).copy(source_dir, new_stem="t1w")

bp = TestDatasetBlueprint(
hierarchy=["session"],
space=Clinical,
dim_lengths=[1, 1, 1],
entries=[
FileBP(path="t1_weighted", datatype=NiftiGz, filenames=["t1w.nii.gz"]),
],
)
hierarchy=["session"],
space=Clinical,
dim_lengths=[1, 1, 1],
entries=[
FileBP(path="t1_weighted", datatype=NiftiGz, filenames=["t1w.nii.gz"]),
],
)

work_dir = Path(tempfile.mkdtemp())

dataset_id = work_dir / "saved-dataset"
saved_dataset = bp.make_dataset(DirTree(), dataset_id, name="", source_data=source_dir)

command_spec = ContainerCommand(
task="arcana.common:shell_cmd",
task="common:shell",
row_frequency=Clinical.session,
inputs=[
{
Expand All @@ -43,7 +43,7 @@
"configuration": {
"argstr": "",
"position": -2,
}
},
},
],
outputs=[
Expand All @@ -54,12 +54,12 @@
"configuration": {
"argstr": "",
"position": -1,
}
},
}
],
configuration={
"executable": "bet",
}
},
)
# Start generating the arguments for the CLI
# Add source to loaded dataset
Expand Down
6 changes: 3 additions & 3 deletions tests/test_build.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from pathlib import Path
from click.testing import CliRunner
from arcana.core.cli.deploy import make_app
from arcana.core.utils.misc import show_cli_trace
from pydra2app.core.cli import make
from frametree.core.utils import show_cli_trace

PKG_PATH = Path(__file__).parent.parent.absolute()

runner = CliRunner()

results = runner.invoke(
make_app,
make,
[
f"{PKG_PATH}/australian-imaging-service-community/",
"xnat:XnatApp",
Expand Down
38 changes: 19 additions & 19 deletions tests/test_zip.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@

from pathlib import Path
import tempfile
import operator as op
import functools
from fileformats.generic import Directory
from fileformats.application import Zip
from arcana.common import DirTree
from arcana.testing import TestDataSpace
from arcana.testing.data.blueprint import (
TestDatasetBlueprint, FileSetEntryBlueprint as FileBP
from frametree.common import DirTree
from frametree.testing import TestDataSpace
from frametree.testing.blueprint import (
TestDatasetBlueprint,
FileSetEntryBlueprint as FileBP,
)
from arcana.core.deploy.command import ContainerCommand
from pydra2app.core.command import ContainerCommand


bp = TestDatasetBlueprint(
hierarchy=[
"abcd"
], # e.g. XNAT where session ID is unique in project but final layer is organised by timepoint
space=TestDataSpace,
dim_lengths=[1, 1, 1, 1],
entries=[
FileBP(path="dir1", datatype=Directory, filenames=["dir"]),
],
)
hierarchy=[
"abcd"
], # e.g. XNAT where session ID is unique in project but final layer is organised by timepoint
space=TestDataSpace,
dim_lengths=[1, 1, 1, 1],
entries=[
FileBP(path="dir1", datatype=Directory, filenames=["dir"]),
],
)

work_dir = Path(tempfile.mkdtemp())

dataset_id = work_dir / "saved-dataset"
saved_dataset = bp.make_dataset(DirTree(), dataset_id, name="")

command_spec = ContainerCommand(
task="arcana.common:shell_cmd",
task="arcana.common:shell",
row_frequency=bp.space.default(),
inputs=[
{
Expand All @@ -40,7 +40,7 @@
"configuration": {
"argstr": "",
"position": -1,
}
},
},
],
outputs=[
Expand All @@ -51,7 +51,7 @@
"configuration": {
"argstr": "",
"position": -2,
}
},
}
],
parameters=[
Expand All @@ -67,7 +67,7 @@
],
configuration={
"executable": "zip",
}
},
)
# Start generating the arguments for the CLI
# Add source to loaded dataset
Expand Down
Loading
Loading