Skip to content

Commit

Permalink
Update ct pipe (#28)
Browse files Browse the repository at this point in the history
* align_ct_on_T1_2

* flake8

* added "align_ct_on_T1_2" by default

* segment_skull
  • Loading branch information
davidmeunier79 authored Dec 12, 2024
1 parent f3e8ccc commit 39b769c
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 80 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build_on_prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
- name: Running all test pipelines (ANTS cenir macaque petra)
run: |
docker run -i -v /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI:/data macatools/skullto3d:latest segment_petra -data /data/cenir-macaque-petra -out /data/cenir-macaque-petra/results -soft ANTS_prep_skull -species macaque -sub Magneto -brain_dt T1 T2 -skull_dt petra -deriv -pad -nprocs 1
docker run -i -v /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI:/data macatools/skullto3d:latest segment_skull -data /data/cenir-macaque-petra -out /data/cenir-macaque-petra/results -soft ANTS_prep_skull -species macaque -sub Magneto -brain_dt T1 T2 -skull_dt petra -deriv -pad -nprocs 1
ls /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cenir-macaque-petra/results
Expand Down Expand Up @@ -140,7 +140,7 @@ jobs:
- name: Running all test pipelines (ANTS cerimed macaque CT)
run: |
docker run -i -v /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI:/data macatools/skullto3d:latest segment_petra -data /data/cerimed-macaque-ct -out /data/cerimed-macaque-ct/results -soft ANTS_prep_skull -species macaque -sub Marvin -ses 01 -brain_dt T1 T2 -skull_dt CT -deriv -pad -nprocs 1
docker run -i -v /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI:/data macatools/skullto3d:latest segment_skull -data /data/cerimed-macaque-ct -out /data/cerimed-macaque-ct/results -soft ANTS_prep_skull -species macaque -sub Marvin -ses 01 -brain_dt T1 T2 -skull_dt CT -deriv -pad -nprocs 1
ls /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-macaque-ct/results
Expand Down Expand Up @@ -186,7 +186,7 @@ jobs:
- name: Running all test pipelines (ANTS cerimed marmo petra)
run: |
docker run -i -v /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI:/data macatools/skullto3d:latest segment_petra -data /data/cerimed-marmo-petra -out /data/cerimed-marmo-petra/results -soft ANTS_noseg_skull -species marmo -sub Paolina -ses 01 -brain_dt T1 T2 -skull_dt T1 petra -deriv -pad -nprocs 1
docker run -i -v /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI:/data macatools/skullto3d:latest segment_skull -data /data/cerimed-marmo-petra -out /data/cerimed-marmo-petra/results -soft ANTS_noseg_skull -species marmo -sub Paolina -ses 01 -brain_dt T1 T2 -skull_dt T1 petra -deriv -pad -nprocs 1
ls /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-marmo-petra/results
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build_on_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
- name: Running all test pipelines (ANTS cenir macaque petra)
run: |
docker run -i -v /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI:/data macatools/skullto3d:latest segment_petra -data /data/cenir-macaque-petra -out /data/cenir-macaque-petra/results -soft ANTS_prep_skull -species macaque -sub Magneto -brain_dt T1 T2 -skull_dt petra -deriv -pad -nprocs 1
docker run -i -v /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI:/data macatools/skullto3d:latest segment_skull -data /data/cenir-macaque-petra -out /data/cenir-macaque-petra/results -soft ANTS_prep_skull -species macaque -sub Magneto -brain_dt T1 T2 -skull_dt petra -deriv -pad -nprocs 1
ls /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cenir-macaque-petra/results
Expand Down Expand Up @@ -141,7 +141,7 @@ jobs:
- name: Running all test pipelines (ANTS cerimed macaque CT)
run: |
docker run -i -v /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI:/data macatools/skullto3d:latest segment_petra -data /data/cerimed-macaque-ct -out /data/cerimed-macaque-ct/results -soft ANTS_prep_skull -species macaque -sub Marvin -ses 01 -brain_dt T1 T2 -skull_dt CT -deriv -pad -nprocs 1
docker run -i -v /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI:/data macatools/skullto3d:latest segment_skull -data /data/cerimed-macaque-ct -out /data/cerimed-macaque-ct/results -soft ANTS_prep_skull -species macaque -sub Marvin -ses 01 -brain_dt T1 T2 -skull_dt CT -deriv -pad -nprocs 1
ls /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-macaque-ct/results
Expand Down Expand Up @@ -186,7 +186,7 @@ jobs:
- name: Running all test pipelines (ANTS cerimed marmo petra)
run: |
docker run -i -v /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI:/data macatools/skullto3d:latest segment_petra -data /data/cerimed-marmo-petra -out /data/cerimed-marmo-petra/results -soft ANTS_noseg_skull -species marmo -sub Paolina -ses 01 -brain_dt T1 T2 -skull_dt T1 petra -deriv -pad -nprocs 1
docker run -i -v /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI:/data macatools/skullto3d:latest segment_skull -data /data/cerimed-marmo-petra -out /data/cerimed-marmo-petra/results -soft ANTS_noseg_skull -species marmo -sub Paolina -ses 01 -brain_dt T1 T2 -skull_dt T1 petra -deriv -pad -nprocs 1
ls /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-marmo-petra/results
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/check_on_PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,31 @@ jobs:
- name: Running all test pipelines (ANTS SPM)
run: |
python workflows/segment_petra.py -data /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cenir-macaque-petra -out /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cenir-macaque-petra/results -soft ANTS_test_skull -species macaque -sub Magneto -brain_dt T1 T2 -skull_dt T1 petra
python workflows/segment_skull.py -data /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cenir-macaque-petra -out /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cenir-macaque-petra/results -soft ANTS_test_skull -species macaque -sub Magneto -brain_dt T1 T2 -skull_dt T1 petra
python workflows/segment_petra.py -data /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-macaque-ct -out /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-macaque-ct/results -soft ANTS_test_skull -species macaque -sub Marvin -ses 01 -brain_dt T1 T2 -skull_dt T1 CT
python workflows/segment_skull.py -data /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-macaque-ct -out /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-macaque-ct/results -soft ANTS_test_skull -species macaque -sub Marvin -ses 01 -brain_dt T1 T2 -skull_dt T1 CT
python workflows/segment_petra.py -data /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-marmo-petra -out /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-marmo-petra/results -soft ANTS_test_skull -species marmo -sub Paolina -ses 01 -brain_dt T1 T2 -skull_dt T1 petra
python workflows/segment_skull.py -data /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-marmo-petra -out /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-marmo-petra/results -soft ANTS_test_skull -species marmo -sub Paolina -ses 01 -brain_dt T1 T2 -skull_dt T1 petra
python workflows/segment_petra.py -data /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cenir-macaque-petra -out /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cenir-macaque-petra/results -soft SPM_native_test_skull -species macaque -sub Magneto -brain_dt T1 T2 -skull_dt T1 petra
python workflows/segment_skull.py -data /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cenir-macaque-petra -out /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cenir-macaque-petra/results -soft SPM_native_test_skull -species macaque -sub Magneto -brain_dt T1 T2 -skull_dt T1 petra
python workflows/segment_petra.py -data /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-macaque-ct -out /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-macaque-ct/results -soft SPM_native_test_skull -species macaque -sub Marvin -ses 01 -brain_dt T1 T2 -skull_dt T1 CT
python workflows/segment_skull.py -data /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-macaque-ct -out /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-macaque-ct/results -soft SPM_native_test_skull -species macaque -sub Marvin -ses 01 -brain_dt T1 T2 -skull_dt T1 CT
python workflows/segment_petra.py -data /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-marmo-petra -out /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-marmo-petra/results -soft SPM_native_test_skull -species marmo -sub Paolina -ses 01 -brain_dt T1 T2 -skull_dt T1 petra
python workflows/segment_skull.py -data /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-marmo-petra -out /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-marmo-petra/results -soft SPM_native_test_skull -species marmo -sub Paolina -ses 01 -brain_dt T1 T2 -skull_dt T1 petra
- name: Running all test pipelines (ANTS SPM deriv pad)
run: |
python workflows/segment_petra.py -data /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cenir-macaque-petra -out /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cenir-macaque-petra/results -soft ANTS_test_skull -species macaque -sub Magneto -brain_dt T1 T2 -skull_dt T1 petra -deriv -pad
python workflows/segment_skull.py -data /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cenir-macaque-petra -out /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cenir-macaque-petra/results -soft ANTS_test_skull -species macaque -sub Magneto -brain_dt T1 T2 -skull_dt T1 petra -deriv -pad
python workflows/segment_petra.py -data /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-macaque-ct -out /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-macaque-ct/results -soft ANTS_test_skull -species macaque -sub Marvin -ses 01 -brain_dt T1 T2 -skull_dt T1 CT -deriv -pad
python workflows/segment_skull.py -data /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-macaque-ct -out /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-macaque-ct/results -soft ANTS_test_skull -species macaque -sub Marvin -ses 01 -brain_dt T1 T2 -skull_dt T1 CT -deriv -pad
python workflows/segment_petra.py -data /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-marmo-petra -out /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-marmo-petra/results -soft ANTS_test_skull -species marmo -sub Paolina -ses 01 -brain_dt T1 T2 -skull_dt T1 petra -deriv -pad
python workflows/segment_skull.py -data /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-marmo-petra -out /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-marmo-petra/results -soft ANTS_test_skull -species marmo -sub Paolina -ses 01 -brain_dt T1 T2 -skull_dt T1 petra -deriv -pad
python workflows/segment_petra.py -data /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cenir-macaque-petra -out /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cenir-macaque-petra/results -soft SPM_native_test_skull -species macaque -sub Magneto -brain_dt T1 T2 -skull_dt T1 petra -deriv -pad
python workflows/segment_skull.py -data /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cenir-macaque-petra -out /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cenir-macaque-petra/results -soft SPM_native_test_skull -species macaque -sub Magneto -brain_dt T1 T2 -skull_dt T1 petra -deriv -pad
python workflows/segment_petra.py -data /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-macaque-ct -out /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-macaque-ct/results -soft SPM_native_test_skull -species macaque -sub Marvin -ses 01 -brain_dt T1 T2 -skull_dt T1 CT -deriv -pad
python workflows/segment_skull.py -data /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-macaque-ct -out /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-macaque-ct/results -soft SPM_native_test_skull -species macaque -sub Marvin -ses 01 -brain_dt T1 T2 -skull_dt T1 CT -deriv -pad
python workflows/segment_petra.py -data /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-marmo-petra -out /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-marmo-petra/results -soft SPM_native_test_skull -species marmo -sub Paolina -ses 01 -brain_dt T1 T2 -skull_dt T1 petra -deriv -pad
python workflows/segment_skull.py -data /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-marmo-petra -out /home/runner/work/skullTo3d/skullTo3d/skullTo3d_CI/cerimed-marmo-petra/results -soft SPM_native_test_skull -species marmo -sub Paolina -ses 01 -brain_dt T1 T2 -skull_dt T1 petra -deriv -pad
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@

include workflows/params*.json

include skullTo3d/_version.py
16 changes: 8 additions & 8 deletions docs/command.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,29 @@ Launching a processing
Commands
********

The main file is located in workflows and is called segment_petra.py and should be called like a python script:
The main file is located in workflows and is called segment_skull.py and should be called like a python script:

.. code:: bash
$ python workflows/segment_petra.py
$ python workflows/segment_skull.py
**N.B. if you have installed the pypi version (e.g. using pip install macapype) or a docker/singularity version, you can replace the previous command by the following command:**

.. code:: bash
$ segment_petra
$ segment_skull
For container (docker and singularity), here are some examples - add your proper bindings:

.. code:: bash
$ docker run -B binding_to_host:binding_guest macatools/skullto3d:latest segment_petra
$ docker run -B binding_to_host:binding_guest macatools/skullto3d:latest segment_skull
.. code:: bash
$ singularity run -v binding_to_host:binding_guest /path/to/containers/skullto3d_v0.0.4.1.sif segment_petra
$ singularity run -v binding_to_host:binding_guest /path/to/containers/skullto3d_v0.0.4.1.sif segment_skull
Expected input data
*******************
Expand Down Expand Up @@ -131,13 +131,13 @@ Command line examples

.. code:: bash
$ python workflows/segment_petra.py -data ~/Data_maca -out ./local_test -soft ANTS_skull -params params.json
$ python workflows/segment_skull.py -data ~/Data_maca -out ./local_test -soft ANTS_skull -params params.json
.. code:: bash
$ python workflows/segment_petra.py -data ~/Data_maca -out ./local_test -soft ANTS_skull_robustreg -species macaque
$ python workflows/segment_skull.py -data ~/Data_maca -out ./local_test -soft ANTS_skull_robustreg -species macaque
.. code:: bash
$ python workflows/segment_petra.py -data ~/Data_maca -out ./local_test -soft ANTS_skull -params params.json -sub Apache Baron -ses 01 -rec mean -deriv -pad
$ python workflows/segment_skull.py -data ~/Data_maca -out ./local_test -soft ANTS_skull -params params.json -sub Apache Baron -ses 01 -rec mean -deriv -pad
50 changes: 50 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[build-system]
requires = [
"setuptools", "wheel"
]
build-backend = "setuptools.build_meta"

[project]
dynamic = ['version']
name = "skullTo3d"
maintainers = [{name = "SkullTo3d developers" }]
authors= [{name = "Macatools team"}]
description= "Pipeline for skull extraction for macaque/marmoset "
readme = {content-type = "text/markdown", file = "README.md"}
requires-python = ">= 3.10"
license = {text = "BSD-3-Clause"}

dependencies = [
"macapype",
"matplotlib"
]

[project.optional-dependencies]
# Dependencies for building the documentation
doc_deps = [
"sphinx",
"sphinx-gallery",
"sphinx_bootstrap_theme",
"numpydoc",
"sphinxcontrib-fulltoc"
]

# Dependencies for test
test_deps = [
"pytest",
"pytest-cov",
"codecov",
]
flake_deps = [
"flake8"
]

# real calls
test=["skullTo3d[test_deps, flake_deps]"]
doc=["skullTo3d[flake_deps, test_deps, doc_deps]"]

[project.scripts]
segment_skull = "workflows.segment_skull:main"

[tool.setuptools.packages]
find = {} # Scanning implicit namespaces is active by default
73 changes: 21 additions & 52 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,59 +1,28 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from setuptools import setup
import re
from setuptools import find_packages, setup

test_deps = ['codecov', 'pytest', 'pytest-cov']

flake_deps = ['flake8']

doc_deps = ['sphinx',
'sphinx-gallery',
'sphinx_bootstrap_theme',
'numpydoc',
'sphinxcontrib-fulltoc',
'matplotlib']

# requirements
with open('requirements.txt') as f:
requirements = f.read().splitlines()

# version
verstr = "unknown"
try:
verstrline = open('skullTo3d/_version.py', "rt").read()
except EnvironmentError:
pass # Okay, there is no version file.
def _get_version():

else:
VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
mo = re.search(VSRE, verstrline, re.M)
if mo:
verstr = mo.group(1)
verstr = "unknown"
try:
verstrline = open('skullTo3d/_version.py', "rt").read()
except EnvironmentError:
pass # Okay, there is no version file.
else:
raise RuntimeError("unable to find version in yourpackage/_version.py")

print("Will not build conda module")

print("*******************************************************")
print(find_packages())
print("*******************************************************")

setup(
name="skullTo3d",
version=verstr,
packages=find_packages(),
author="macatools team",
description="Pipeline for skull extraction for macaque/marmoset",
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
license='BSD 3',
entry_points={
'console_scripts': ['segment_petra = workflows.segment_petra:main']},
extras_require={
'test': test_deps + flake_deps,
'doc': flake_deps + test_deps + doc_deps
},
install_requires=requirements,
include_package_data=True)
VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
mo = re.search(VSRE, verstrline, re.M)
if mo:
verstr = mo.group(1)
else:
raise RuntimeError(
"unable to find version in yourpackage/_version.py")
return verstr


if __name__ == "__main__":
setup(
version=_get_version()
)
23 changes: 21 additions & 2 deletions skullTo3d/pipelines/skull_pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,32 @@ def create_skull_ct_pipe(name="skull_ct_pipe", params={}):
skull_ct_pipe.connect(inputnode, "native_T1",
align_ct_on_T1, "ref_file")

if "align_ct_on_T1_2" in params:

# align_ct_on_T1
align_ct_on_T1_2 = pe.Node(interface=RegAladin(),
name="align_ct_on_T1_2")

align_ct_on_T1_2.inputs.rig_only_flag = True

skull_ct_pipe.connect(align_ct_on_T1, 'res_file',
align_ct_on_T1_2, "flo_file")

skull_ct_pipe.connect(inputnode, "native_T1",
align_ct_on_T1_2, "ref_file")

# align_ct_on_stereo_T1
align_ct_on_stereo_T1 = pe.Node(
interface=RegResample(pad_val=0.0),
name="align_ct_on_stereo_T1")

skull_ct_pipe.connect(align_ct_on_T1, 'res_file',
align_ct_on_stereo_T1, "flo_file")
if "align_ct_on_T1_2" in params:
skull_ct_pipe.connect(align_ct_on_T1_2, 'res_file',
align_ct_on_stereo_T1, "flo_file")

else:
skull_ct_pipe.connect(align_ct_on_T1, 'res_file',
align_ct_on_stereo_T1, "flo_file")

skull_ct_pipe.connect(inputnode, 'native_to_stereo_trans',
align_ct_on_stereo_T1, "trans_file")
Expand Down
3 changes: 3 additions & 0 deletions workflows/params_segment_macaque_ants_skull.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@
},
"skull_ct_pipe":
{
"align_ct_on_T1_2":
{
},
"ct_skull_auto_mask":
{
"kmeans": true,
Expand Down
2 changes: 2 additions & 0 deletions workflows/params_segment_marmo_ants_skull.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"use_T2":{},
"crop_aladin_pipe":
{
"remove_capsule_pipe":{},

"reg_T1_on_template":
{
"nac_flag": true,
Expand Down
File renamed without changes.

0 comments on commit 39b769c

Please sign in to comment.