Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
181 commits
Select commit Hold shift + click to select a range
e2bd325
WIP: Add download_brain_atlas function to download Cucaracha models f…
acsenrafilho Jun 13, 2025
eee3b05
ENH: Add antspyx and kagglehub dependencies to pyproject.toml
acsenrafilho Jun 13, 2025
75eafd8
WIP: Add Brain Atlas data structure and methods for atlas management
acsenrafilho Jun 13, 2025
0c9cce9
ENH: Create __init__.py for asltk.data package initialization
acsenrafilho Jun 13, 2025
bf69a0b
WIP: Implement brain normalization function for image registration us…
acsenrafilho Jun 13, 2025
720d648
Implement code changes to enhance functionality and improve performance
acsenrafilho Jun 13, 2025
4b69bc7
ENH: Refactor BrainAtlas class to remove hardcoded atlas data and imp…
acsenrafilho Jun 14, 2025
31d44b3
ENH: Add multiple brain atlas JSON files with metadata and descriptions
acsenrafilho Jun 14, 2025
d1ab203
ENH: Add multiple brain atlas JSON files with metadata and descriptions
acsenrafilho Jun 14, 2025
24429d9
ENH: Add unit tests for BrainAtlas class to validate atlas listing an…
acsenrafilho Jun 14, 2025
9d862cf
STY: Clean up whitespace and ensure consistent formatting in download…
acsenrafilho Jun 14, 2025
0d58852
ENH: Remove unused kaggle_tools.py file and associated download_brain…
acsenrafilho Jun 17, 2025
246a8f0
ENH: Update MNI2009.json to include dataset URL and detailed labels f…
acsenrafilho Jun 17, 2025
54d6e49
ENH: Refactor BrainAtlas class to improve atlas loading and error han…
acsenrafilho Jun 17, 2025
d1389e6
ENH: Refactor brain normalization function to space normalization, im…
acsenrafilho Jun 17, 2025
d8a8203
ENH: Add comprehensive tests for rigid body registration and head mov…
acsenrafilho Jun 17, 2025
826bf78
ENH: Add data.brain_atlas reference to documentation and include it i…
acsenrafilho Jun 17, 2025
d4dfc1c
ENH: Add initial test suite for registration module
acsenrafilho Jun 17, 2025
bcab0c1
ENH: Implement space normalization function and head movement correct…
acsenrafilho Jun 17, 2025
f1df03f
ENH: Refactor registration tests to improve error handling and add co…
acsenrafilho Jun 17, 2025
d312417
ENH: Add tests for head movement correction function, including succe…
acsenrafilho Jun 17, 2025
163bfbd
ENH: Add tests for error handling in setting atlas and retrieving URL…
acsenrafilho Jun 17, 2025
b8f1092
ENH: Update Python version matrix in CI workflows to include 3.11, 3.…
acsenrafilho Jun 17, 2025
c58cca5
ENH: Improve docstring for head movement correction function to clari…
acsenrafilho Jun 17, 2025
198c220
ENH: Update code formatting check step in CI workflow to use 'lint_ch…
acsenrafilho Jun 17, 2025
b1dd577
ENH: Update CI workflow to use 'lint_check' task for code formatting …
acsenrafilho Jun 17, 2025
7c91456
ENH: Add dataset DOI and citation DOIs to MNI2009 brain atlas JSON
acsenrafilho Jun 17, 2025
7bf31b8
ENH: Update Python version matrix in CI workflows to include 3.11, 3.…
acsenrafilho Jun 17, 2025
076c6c5
ENH: Remove Python 3.13 from version matrix in CI workflows for devel…
acsenrafilho Jun 17, 2025
0d5faaf
ENH: Add workflow_dispatch trigger to CI for develop branch
acsenrafilho Jun 17, 2025
0dcf6ce
ENH: Add test for ParcellationReport class to validate report generat…
acsenrafilho Jun 17, 2025
f2ecce3
ENH: Implement BasicReport and ParcellationReport classes for report …
acsenrafilho Jun 17, 2025
7074076
ENH: Update Python version matrix in CI workflows to only include 3.9…
acsenrafilho Jun 17, 2025
7b7f7dc
ENH: Add LGPHCC2022 brain atlas JSON file and remove obsolete LGPHCCx…
acsenrafilho Jun 18, 2025
378473b
ENH: Add AICHA2021 brain atlas JSON file and remove obsolete AICHAxxx…
acsenrafilho Jun 18, 2025
6650a71
ENH: Add AAL32024 brain atlas JSON file and remove obsolete AAL2015 file
acsenrafilho Jun 18, 2025
71168f2
ENH: Add additional metadata fields to brain atlas JSON files for CAP…
acsenrafilho Jun 18, 2025
0cb965e
ENH: Add JHA2005 brain atlas JSON file and remove obsolete JHAxxxx file
acsenrafilho Jun 18, 2025
3c35fd0
ENH: Add FCA7N2011 brain atlas JSON file and remove obsolete FCA7Nxxx…
acsenrafilho Jun 18, 2025
05ef4ff
ENH: Update AAT2022 brain atlas JSON file with dataset URL, DOI, and …
acsenrafilho Jun 18, 2025
1ea21ea
ENH: Update HOCSA2006 brain atlas JSON file with dataset URL, DOI, an…
acsenrafilho Jun 18, 2025
75f3f0a
ENH: Update description in MA2012 brain atlas JSON file for clarity
acsenrafilho Jun 18, 2025
d199cf3
STY: fix linter
acsenrafilho Jun 18, 2025
95da826
WIP: Parcellation Report partial implementation
acsenrafilho Jun 18, 2025
d4eb8ca
ENH: Remove deprecated brain atlas JSON files and add updated version…
acsenrafilho Jun 18, 2025
4cffbe5
STY: Fix linter
acsenrafilho Jun 18, 2025
a4292ee
STY: Fix linter and isort
acsenrafilho Jun 18, 2025
209c483
BUG: Correct JSON formatting in HOCSA2006 brain atlas file
acsenrafilho Jun 18, 2025
6d94560
ENH: Add unit tests for BrainAtlas class functionality
acsenrafilho Jun 18, 2025
60d042b
WIP: ParcellationReport tests
acsenrafilho Jun 18, 2025
bf4162b
BUG: Update mask loading to handle numpy arrays in space_normalizatio…
acsenrafilho Jun 18, 2025
25c7d1e
ENH: Implement ASL data registration with normalization and error han…
acsenrafilho Jun 18, 2025
5f8446d
WIP: Fix file path for saving regions DataFrame in ParcellationReport
acsenrafilho Jun 18, 2025
cc67420
ENH: Add tests for asl_template_registration function to validate inp…
acsenrafilho Jun 18, 2025
720c394
ENH: Implement progress bar for volume registration in asl_template_r…
acsenrafilho Jun 20, 2025
9462c31
ENH: Add tests for apply_transformation function to validate output a…
acsenrafilho Jun 21, 2025
31a0502
WIP: Adjusting asl_template_registration method
acsenrafilho Jun 21, 2025
f758054
ENH: Add tests for ASLData class to validate copy behavior and length…
acsenrafilho Jun 21, 2025
8f3175b
ENH: Implement deep copy method for ASLData class and add length calc…
acsenrafilho Jun 21, 2025
68f49f1
STY: Remove outdated TODO comments related to atlas resources and com…
acsenrafilho Jun 21, 2025
58c5c99
DOC: Add Brain Parcellation Reports module and update navigation in m…
acsenrafilho Jun 21, 2025
d91798e
ENH: Add apply_transformation function to apply a list of transformat…
acsenrafilho Jun 21, 2025
91bb9bd
ENH: Remove console logging from space_normalization function to stre…
acsenrafilho Jun 21, 2025
c93f6bb
ENH: Refactor asl_template_registration to improve normalization proc…
acsenrafilho Jun 21, 2025
f878247
DOC: Update docstrings in BasicReport class for improved clarity and …
acsenrafilho Jun 21, 2025
6195d38
BUG: Fix linter
acsenrafilho Jun 21, 2025
69d695f
ENH: Update lint task name to lint_check in CI workflows for consistency
acsenrafilho Jun 21, 2025
9a5dcd6
BUG: Improve docstring for copy method in ASLData class for clarity
acsenrafilho Jun 21, 2025
9ea763f
ENH: Update pre_test task to use lint_check for consistency in CI wor…
acsenrafilho Jun 21, 2025
d0f35a0
WIP: Fixing asl_template_normalization to use M0 volume first
acsenrafilho Jun 23, 2025
1dc7e48
BUG: Improve type checks in apply_transformation function for moving …
acsenrafilho Jun 23, 2025
bdfd70b
ENH: Refactor asl_template_registration to prioritize M0 image for no…
acsenrafilho Jun 23, 2025
6a73181
ENH: Implement tests for asl_template_registration to validate succes…
acsenrafilho Jun 23, 2025
2c5524f
ENH: Add tests for apply_transformation with BrainAtlas reference inp…
acsenrafilho Jun 23, 2025
43241af
BUG: Update error messages in apply_transformation tests for clarity …
acsenrafilho Jun 25, 2025
9ae8803
WIP: commenting asl_template_registration tests for a while
acsenrafilho Jun 25, 2025
771500c
STY: Refactor asl_template_registration for improved readability and …
acsenrafilho Jun 25, 2025
b667de1
BUG: Fix type checking for reference_image in apply_transformation fu…
acsenrafilho Jun 25, 2025
e50df28
ENH: Add pytest-mock dependency for improved testing capabilities
acsenrafilho Jun 25, 2025
8f6b67c
ENH: Add tests for BasicReport and ASLData, including error handling …
acsenrafilho Jun 25, 2025
e8676fa
DOC: Update import path for load_image and save_image functions in ge…
acsenrafilho Jun 25, 2025
0dfbec2
STY: Refactor import paths for load_image and save_image functions; r…
acsenrafilho Jun 25, 2025
729e02e
ENH: Implement load_image and save_image functions for BIDS directory…
acsenrafilho Jun 25, 2025
d478659
STY: Update import path for collect_data_volumes in gaussian.py
acsenrafilho Jun 25, 2025
08719f0
STY: Add TODO comments for fixing T1 data loading and adjusting Kaggl…
acsenrafilho Jun 25, 2025
a69549b
REF: Update import paths and replace ants.image_read with load_image …
acsenrafilho Jun 25, 2025
fd3e685
WIP: New modules to image orientation validation
acsenrafilho Jun 25, 2025
c0b30aa
Merge remote-tracking branch 'origin/main' into issue-26
acsenrafilho Jun 29, 2025
e876773
Merge remote-tracking branch 'origin/develop' into issue-26
acsenrafilho Jul 2, 2025
4f37a79
ENH: Add unit tests for rigid body registration and head movement cor…
acsenrafilho Jul 2, 2025
99d813e
STY: Remove commented-out test placeholder for brain mask dimension c…
acsenrafilho Jul 2, 2025
0c36c5e
WIP: Implement initial structure for ASLRegistration class with pipel…
acsenrafilho Jul 2, 2025
c77e21d
DOC: Add initial Copilot instructions for ASL toolkit usage and guide…
acsenrafilho Jul 4, 2025
1ee5270
ENH: Add VSCode settings for Python testing configuration and commit …
acsenrafilho Jul 4, 2025
ea90391
ENH: Improve ASL template registration by normalizing pcasl volumes a…
acsenrafilho Jul 4, 2025
64143bb
Merge remote-tracking branch 'origin/develop' into issue-26
acsenrafilho Jul 9, 2025
11c9e31
ENH: Fix linter and merge conflicts
acsenrafilho Jul 9, 2025
11bbfc8
ENH: Simplify workflow names for CI configurations
acsenrafilho Jul 9, 2025
ef8bdb8
BUG: Update lint check task name in CI workflows for consistency
acsenrafilho Jul 9, 2025
7cacd3a
BUG: Update assertion in test_basic_report_generate_report_abstract_m…
acsenrafilho Jul 9, 2025
ad82960
Merge remote-tracking branch 'origin/develop' into issue-26
acsenrafilho Jul 9, 2025
88b166a
ENH: Remove unused parameter from asl_template_registration and delet…
acsenrafilho Jul 11, 2025
0080b8a
ENH: Remove unused ASLRegistration class and add tests for head movem…
acsenrafilho Jul 11, 2025
ec61e42
ENH: Refactor space_normalization function by removing unused paramet…
acsenrafilho Jul 16, 2025
8b96092
DOC: Improve ASLData constructor documentation for clarity and detail
acsenrafilho Jul 16, 2025
ff61aa5
ENH: Improve image resizing logic and optimize orientation analysis f…
acsenrafilho Jul 16, 2025
b80c279
WIP: Update test_space_normalization_success to use actual ASLData pa…
acsenrafilho Jul 16, 2025
31610a9
BUG: Fix M0 image loading to support both file paths and numpy arrays
acsenrafilho Jul 26, 2025
f00b935
ENH: Implement image loading test for M0 using numpy array
acsenrafilho Jul 26, 2025
aef2ec0
ENH: Add test for creating ASLData object with PCASL as numpy array a…
acsenrafilho Jul 26, 2025
0222cbf
DOC: Improve head movement correction function with detailed docstrin…
acsenrafilho Jul 26, 2025
d612129
BUG: Support loading ASL image from numpy array in ASLData initializa…
acsenrafilho Jul 26, 2025
03ce5cf
ENH: Add new test files for image manipulation and statistics, includ…
acsenrafilho Jul 28, 2025
08658f4
ENH: Implement calculate_snr and analyze_image_properties functions f…
acsenrafilho Jul 28, 2025
3e8a264
ENH: Refactor image property analysis by removing redundant function …
acsenrafilho Jul 28, 2025
2f0be9c
REF: Refactor smoothing functionality by moving it to aux_methods.py …
acsenrafilho Jul 16, 2025
46d2936
REF: Update smoothing function references in CBF, MultiDW, and MultiT…
acsenrafilho Jul 16, 2025
664ed65
Add T2Scalar_ASLMapping to __all__ in __init__.py
acsenrafilho Jul 16, 2025
6448b83
WIP: Add T2Scalar_ASLMapping initial implementation
acsenrafilho Jul 16, 2025
b54303d
Add unit tests for MultiTE and T2Scalar ASL mapping functionalities
acsenrafilho Jul 16, 2025
16fb792
WIP: Refactor T2Scalar_ASLMapping: streamline initialization, enhance…
acsenrafilho Jul 16, 2025
ee02832
Remove unused import of asl_t2_scalar_multi_te from t2_mapping.py
acsenrafilho Jul 16, 2025
caedad7
Refactor T2Scalar_ASLMapping: improve multiprocessing handling, enhan…
acsenrafilho Jul 17, 2025
d212e27
TEST: Add tests for handling DW values in ASL data, T2 map retrieval,…
acsenrafilho Jul 18, 2025
4277430
TEST: Add median smoothing tests with default parameters, different s…
acsenrafilho Jul 18, 2025
bbbe978
ENH: Refactor T2Scalar_ASLMapping: enhance error handling for TE/PLD …
acsenrafilho Jul 18, 2025
f30e6a9
STY: Remove commented TODO regarding LD/PLD size check in CBFMapping.…
acsenrafilho Jul 18, 2025
8911fc3
ENH: Add validation for smoothing_params in _apply_smoothing_to_maps …
acsenrafilho Jul 18, 2025
fb6292f
DOC: Add Copilot instructions and code commit guidelines
acsenrafilho Jul 18, 2025
17b3cff
DOC: Improve documentation for T2Scalar_ASLMapping class and load_ima…
acsenrafilho Jul 18, 2025
224fe37
ENH: Add T2 Scalar Mapping script with argument parsing and processin…
acsenrafilho Jul 18, 2025
bb0c9d2
ENH: Add T2 Scalar Mapping script documentation and update navigation…
acsenrafilho Jul 18, 2025
f948805
ENH: Add script entries for ASLTK command line tools in pyproject.toml
acsenrafilho Jul 18, 2025
2f00be8
ENH: Update command usage in documentation and script help for clarity
acsenrafilho Jul 18, 2025
575a644
BUG: Fix M0 image loading to support both file paths and numpy arrays
acsenrafilho Jul 26, 2025
9541081
ENH: Implement image loading test for M0 using numpy array
acsenrafilho Jul 26, 2025
3a2144a
ENH: Add test for creating ASLData object with PCASL as numpy array a…
acsenrafilho Jul 26, 2025
e436bf0
BUG: Support loading ASL image from numpy array in ASLData initializa…
acsenrafilho Jul 26, 2025
100a338
ENH: Improve SNR and mean intensity calculations with ROI support and…
acsenrafilho Jul 30, 2025
b1cc71b
ENH: Add tests for calculate_mean_intensity and improve calculate_snr…
acsenrafilho Jul 30, 2025
b8b9480
ENH: Add reference volume selection functionality with SNR and mean i…
acsenrafilho Jul 30, 2025
c8472ea
DOC: Update copilot instructions with detailed commit message guideli…
acsenrafilho Jul 30, 2025
0d34af9
ENH: Rename parameter 'transformation_matrix' to 'transforms' in appl…
acsenrafilho Jul 30, 2025
a6675c7
ENH: Improve ASLData class by adding warnings for 4D M0 images and av…
acsenrafilho Jul 30, 2025
1da23c6
ENH: Refactor image loading and saving in tests, add error handling f…
acsenrafilho Jul 30, 2025
0a0cb79
ENH: Enhance head movement correction by adding flexible reference vo…
acsenrafilho Jul 30, 2025
101c9dd
ENH: Add select_reference_volume function and corresponding tests for…
acsenrafilho Jul 30, 2025
07fc248
ENH: Update error message for invalid reference volume and add valida…
acsenrafilho Jul 30, 2025
014b59e
STY: Update import statement for load_image to correct module path
acsenrafilho Jul 30, 2025
bbb980d
STY: Update import statement for load_image to correct module path
acsenrafilho Jul 30, 2025
73e5ddf
STY: Update import statement for load_image to correct module path
acsenrafilho Jul 30, 2025
10116c7
Add T2Scalar_ASLMapping to __all__ in __init__.py
acsenrafilho Jul 16, 2025
842bcad
Add unit tests for MultiTE and T2Scalar ASL mapping functionalities
acsenrafilho Jul 16, 2025
fcd352c
Refactor T2Scalar_ASLMapping: improve multiprocessing handling, enhan…
acsenrafilho Jul 17, 2025
b8c9d17
DOC: Add Copilot instructions and code commit guidelines
acsenrafilho Jul 18, 2025
85dc6b0
ENH: Bumpversion v0.5.0
acsenrafilho Jul 18, 2025
35dc124
Add T2Scalar_ASLMapping to __all__ in __init__.py
acsenrafilho Jul 16, 2025
a506856
Add unit tests for MultiTE and T2Scalar ASL mapping functionalities
acsenrafilho Jul 16, 2025
46de50c
Refactor T2Scalar_ASLMapping: improve multiprocessing handling, enhan…
acsenrafilho Jul 17, 2025
83b76e9
Add T2Scalar_ASLMapping to __all__ in __init__.py
acsenrafilho Jul 16, 2025
1a4e2d7
WIP: Add T2Scalar_ASLMapping initial implementation
acsenrafilho Jul 16, 2025
524c903
Add unit tests for MultiTE and T2Scalar ASL mapping functionalities
acsenrafilho Jul 16, 2025
9d3a644
WIP: Refactor T2Scalar_ASLMapping: streamline initialization, enhance…
acsenrafilho Jul 16, 2025
1b9c12c
Refactor T2Scalar_ASLMapping: improve multiprocessing handling, enhan…
acsenrafilho Jul 17, 2025
9d8a7ac
Add T2Scalar_ASLMapping to __all__ in __init__.py
acsenrafilho Jul 16, 2025
537d4b6
WIP: Add T2Scalar_ASLMapping initial implementation
acsenrafilho Jul 16, 2025
eda9d13
Add unit tests for MultiTE and T2Scalar ASL mapping functionalities
acsenrafilho Jul 16, 2025
9176e2c
WIP: Refactor T2Scalar_ASLMapping: streamline initialization, enhance…
acsenrafilho Jul 16, 2025
44c1e93
Refactor T2Scalar_ASLMapping: improve multiprocessing handling, enhan…
acsenrafilho Jul 17, 2025
7c28388
Merge remote-tracking branch 'origin/main' into issue-26
acsenrafilho Jul 30, 2025
2ede82d
Merge remote-tracking branch 'origin/main' into develop
acsenrafilho Jul 30, 2025
f0e920f
ENH: Implement image loading test for M0 using numpy array
acsenrafilho Jul 26, 2025
5497fdc
ENH: Add test for creating ASLData object with PCASL as numpy array a…
acsenrafilho Jul 26, 2025
6c6eb92
ENH: Implement image loading test for M0 using numpy array
acsenrafilho Jul 26, 2025
10293d4
ENH: Implement image loading test for M0 using numpy array
acsenrafilho Jul 26, 2025
b09f672
Merge remote-tracking branch 'origin/develop' into issue-26
acsenrafilho Jul 30, 2025
2df0d53
STY: Fix linter
acsenrafilho Jul 30, 2025
6b1f56b
STY: Remove unused import of load_image from asltk.utils
acsenrafilho Jul 30, 2025
64c727c
DEL: Remove copilot instructions document
acsenrafilho Jul 30, 2025
f598436
STY: Comment out unused imports and class definitions in report modul…
acsenrafilho Jul 31, 2025
3737a8d
Merge pull request #28 from LOAMRI/issue-26
acsenrafilho Jul 31, 2025
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
23 changes: 23 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# ASL toolkit Copilot Instructions

- Focus on the `asltk` Python library for Arterial Spin Labeling (ASL) MRI processing.
- Prefer code and APIs from the workspace (e.g., `asltk.asldata`, `asltk.reconstruction`, `asltk.utils`).
- Use concise, clear bullet points and code examples.
- Reference workspace files and symbols with links when possible.
- Follow the project's coding style and documentation patterns (Google-style docstrings).
- Suggest improvements or fixes based on the workspace context.
- Avoid general Python advice unless relevant to the workspace.
- Respect the project's contribution guidelines and code of conduct.
- Highlight available scripts in `asltk/scripts` for common workflows.
- Use supported image formats: `.nii`, `.nii.gz`, `.mha`, `.nrrd`.
- Ensure that the code is syntactically correct and adheres to the project's coding standards.
- Be sure about the documentation and comments. They should be clear and concise and use the correct Python docstring format.
- Create commit messages with a detailed description of the changes made, including any bug fixes or new features.
- Be as much specific as possible in the commit messages, including the files affected and the nature of the changes.
- Uses for commit messages prefixes the following pattern:
- `ENH:` for new features and code enhancements
- `BUG:` for bug fixes and general corrections
- `DOC:` for documentation changes
- `STY:` for formatting changes (not affecting code logic)
- `TEST:` for adding or modifying tests

12 changes: 0 additions & 12 deletions .github/copilot_instructions.md

This file was deleted.

15 changes: 8 additions & 7 deletions .github/workflows/ci_develop.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
name: ASLtk Continuous Integration for Develop Branch
name: CI for Develop Branch
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
workflow_dispatch:

jobs:
linux:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10"]
python-version: ["3.9"]


steps:
Expand All @@ -32,7 +33,7 @@ jobs:
run: poetry install

- name: Run code formatting check
run: poetry run task lint
run: poetry run task lint-check

- name: Run project tests
run: poetry run task test --cov-report=xml --ignore-glob='./asltk/scripts/*.py'
Expand All @@ -47,7 +48,7 @@ jobs:
runs-on: windows-latest
strategy:
matrix:
python-version: ["3.9", "3.10"]
python-version: ["3.9"]

steps:
- name: Clone repo
Expand All @@ -69,7 +70,7 @@ jobs:
run: poetry install

- name: Run code formatting check
run: poetry run task lint
run: poetry run task lint-check

- name: Run project tests
run: poetry run task test --cov-report=xml --ignore-glob='./asltk/scripts/*.py'
Expand All @@ -84,7 +85,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
python-version: ["3.9", "3.10"]
python-version: ["3.9"]

steps:
- name: Clone repo
Expand All @@ -103,7 +104,7 @@ jobs:
run: poetry install

- name: Run code formatting check
run: poetry run task lint
run: poetry run task lint-check

- name: Run project tests
run: poetry run task test --cov-report=xml --ignore-glob='./asltk/scripts/*.py'
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/ci_main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ASLtk Continuous Integration for Production Branch
name: CI for Production Branch
on:
push:
branches: [ main ]
Expand All @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10"]
python-version: ["3.9"]


steps:
Expand All @@ -32,7 +32,7 @@ jobs:
run: poetry install

- name: Run code formatting check
run: poetry run task lint
run: poetry run task lint-check

- name: Run project tests
run: poetry run task test --cov-report=xml --ignore-glob='./asltk/scripts/*.py'
Expand All @@ -47,7 +47,7 @@ jobs:
runs-on: windows-latest
strategy:
matrix:
python-version: ["3.9", "3.10"]
python-version: ["3.9"]

steps:
- name: Clone repo
Expand All @@ -69,7 +69,7 @@ jobs:
run: poetry install

- name: Run code formatting check
run: poetry run task lint
run: poetry run task lint-check

- name: Run project tests
run: poetry run task test --cov-report=xml --ignore-glob='./asltk/scripts/*.py'
Expand All @@ -84,7 +84,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
python-version: ["3.9", "3.10"]
python-version: ["3.9"]

steps:
- name: Clone repo
Expand All @@ -103,7 +103,7 @@ jobs:
run: poetry install

- name: Run code formatting check
run: poetry run task lint
run: poetry run task lint-check

- name: Run project tests
run: poetry run task test --cov-report=xml --ignore-glob='./asltk/scripts/*.py'
Expand Down
12 changes: 12 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"github.copilot.chat.commitMessageGeneration.instructions": [
{
"text": "Use conventional commit message format and be as precise and clear as possible. Try to include relevante information that will be useful to create the project realease note. Also use the following prefix patters: ENH: for commits that gives general enhancements and improvements in the code, DOC: commits that give majority documentation and explanations contributios, BUG: commits that fixes bugs or general errors, STY: commits that adjust code styling."
}
]
}
5 changes: 5 additions & 0 deletions asltk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import os

BIDS_IMAGE_FORMATS = ('.nii', '.nii.gz')
AVAILABLE_IMAGE_FORMATS = ('.nii', '.nii.gz', '.mha', '.nrrd')

PARCELLATION_REPORT_PATH = os.path.join(
os.path.expanduser('~'), 'asltk', os.path.sep, 'parcellation_reports'
)
# Import logging functionality for easy access
from .logging_config import configure_for_scripts, get_logger, setup_logging

Expand Down
132 changes: 105 additions & 27 deletions asltk/asldata.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import copy
import os
import warnings

import numpy as np

from asltk.logging_config import get_logger, log_data_info
from asltk.utils import load_image
from asltk.logging_config import get_logger, log_data_info, log_function_call
from asltk.utils.image_manipulation import collect_data_volumes
from asltk.utils.io import load_image


class ASLData:
Expand All @@ -13,43 +16,42 @@ def __init__(
):
"""ASLData constructor

The basic data need to represent a ASL data is the full path to load
the image file, the Labeling Duration (LD) array and the Post-labeling
Delay (PLD) array. Is none of those information is passed, a null
ASLData object is created, which can be further been fed using the
get/set methods.
The basic data needed to represent ASL data are:
- The full path to load the image file
- The Labeling Duration (LD) array
- The Post-labeling Delay (PLD) array

The constructor is generic for classic ASL data and also for multi-TE
and Diffusion-Weighted (DW) ASL protocols. There is a specfic get/set
method for TE/DW data. If TE/DW is not provided, then it is assumed as
type `None` for those data properties. In order to informs the TE or DW
values in the object instance, you can use the tags `te_values` or
`dw_values` in the construction call
If none of these are provided, a null ASLData object is created, which can be further populated using the get/set methods.

The constructor supports classic ASL data, multi-TE, and Diffusion-Weighted (DW) ASL protocols.
There are specific get/set methods for TE/DW data. If TE/DW is not provided, those properties are set to `None`.
To provide TE or DW values, use the `te_values` or `dw_values` keyword arguments.

Examples:
By default, the LD and PLD arrays are indicated (as empty lists)
By default, the LD and PLD arrays are empty lists.

>>> data = ASLData()
>>> data.get_ld()
[]
>>> data.get_pld()
[]

>>> data = ASLData(te_values=[13.0,20.2,50.5,90.5,125.2])
>>> data = ASLData(te_values=[13.0, 20.2, 50.5, 90.5, 125.2])
>>> data.get_te()
[13.0, 20.2, 50.5, 90.5, 125.2]

>>> data = ASLData(dw_values=[13.0,20.2,50.5,90.5,125.2])
>>> data = ASLData(dw_values=[13.0, 20.2, 50.5, 90.5, 125.2])
>>> data.get_dw()
[13.0, 20.2, 50.5, 90.5, 125.2]

Other parameters: Set the ASL data parameters
Other parameters:
pcasl (str, optional): The ASL data full path with filename. Defaults to ''.
m0 (str, optional): The M0 data full path with filename. Defaults to ''.
ld_values (list, optional): The LD values. Defaults to [].
pld_values (list, optional): The PLD values. Defaults to [].
te_values (list, optional): The TE values. Defaults to None.
dw_values (list, optional): The DW values. Defaults to None.
average_m0 (bool, optional): If True, average the M0 image across the first dimension. This may be helpful for MRI acquisitions that collect an subset sample of M0 volumes and take the average of it. Defaults to False.
"""
self._asl_image = None
self._m0_image = None
Expand All @@ -64,18 +66,43 @@ def __init__(
logger.info('Creating ASLData object')

if kwargs.get('pcasl') is not None:
pcasl_path = kwargs.get('pcasl')
logger.info(f'Loading ASL image from: {pcasl_path}')
self._asl_image = load_image(pcasl_path)
if self._asl_image is not None:
log_data_info('ASL image', self._asl_image.shape, pcasl_path)
if isinstance(kwargs.get('pcasl'), str):
pcasl_path = kwargs.get('pcasl')
logger.info(f'Loading ASL image from: {pcasl_path}')
self._asl_image = load_image(pcasl_path)
if self._asl_image is not None:
log_data_info(
'ASL image', self._asl_image.shape, pcasl_path
)
elif isinstance(kwargs.get('pcasl'), np.ndarray):
self._asl_image = kwargs.get('pcasl')
logger.info('ASL image loaded as numpy array')
log_data_info(
'ASL image', self._asl_image.shape, 'numpy array'
)

if kwargs.get('m0') is not None:
m0_path = kwargs.get('m0')
logger.info(f'Loading M0 image from: {m0_path}')
self._m0_image = load_image(m0_path)
if self._m0_image is not None:
log_data_info('M0 image', self._m0_image.shape, m0_path)
if isinstance(kwargs.get('m0'), str):
m0_path = kwargs.get('m0')
logger.info(f'Loading M0 image from: {m0_path}')
self._m0_image = load_image(m0_path)

# Check if M0 image is 4D and warn if so
if (
self._m0_image is not None
and len(self._m0_image.shape) > 3
):
warnings.warn('M0 image has more than 3 dimensions.')

if self._m0_image is not None:
log_data_info('M0 image', self._m0_image.shape, m0_path)
elif isinstance(kwargs.get('m0'), np.ndarray):
self._m0_image = kwargs.get('m0')
logger.info('M0 image loaded as numpy array')
log_data_info('M0 image', self._m0_image.shape, 'numpy array')

if kwargs.get('average_m0', False):
self._m0_image = np.mean(self._m0_image, axis=0)

self._parameters['ld'] = (
[] if kwargs.get('ld_values') is None else kwargs.get('ld_values')
Expand Down Expand Up @@ -142,6 +169,11 @@ def set_image(self, image, spec: str):
self._m0_image = image
elif spec == 'pcasl':
self._asl_image = image
else:
raise ValueError(
f'Invalid image type or path: {image}. '
'Please provide a valid file path or a numpy array.'
)

def get_ld(self):
"""Obtain the LD array values"""
Expand Down Expand Up @@ -215,6 +247,30 @@ def set_dw(self, dw_values: list):
self._check_input_parameter(dw_values, 'DW')
self._parameters['dw'] = dw_values

def copy(self):
"""
Make a copy of the ASLData object.
This method creates a deep copy of the ASLData object, including all
its attributes and data. It is useful when you want to preserve the
original object while working with a modified version.

Note:
This method uses `copy.deepcopy` to ensure that all nested objects
are also copied, preventing any unintended side effects from
modifying the original object.

Examples:
>>> data = ASLData(pcasl='./tests/files/t1-mri.nrrd')
>>> data_copy = data.copy()
>>> type(data_copy)
<class 'asltk.asldata.ASLData'>


Returns:
ASLData: A new instance of ASLData that is a deep copy of the original object.
"""
return copy.deepcopy(self)

def __call__(self, spec: str):
"""Object caller to expose the image data.

Expand All @@ -234,6 +290,20 @@ def __call__(self, spec: str):
elif spec == 'm0':
return self._m0_image

def __len__(self):
"""Return the number of volumes in the ASL data.

This method returns the number of volumes in the ASL data based on
the pCASL image format.

Returns:
int: The number of volumes in the ASL data considering the `pcasl` data.
"""
if self._asl_image is not None:
return len(collect_data_volumes(self._asl_image)[0])
else:
return 0

def _check_input_parameter(self, values, param_type):
for v in values:
if not isinstance(v, int) and not isinstance(v, float):
Expand All @@ -255,3 +325,11 @@ def _check_ld_pld_sizes(self, ld, pld):
logger.debug(
f'LD and PLD size validation passed: {len(ld)} elements each'
)

def _check_m0_dimension(self):
if len(self._m0_image.shape) > 3:
warnings.warn(
'M0 image has more than 3 dimensions. '
'This may cause issues in processing. '
'Consider averaging the M0 image across the first dimension.'
)
Empty file added asltk/data/__init__.py
Empty file.
Loading
Loading