A Torso Processing Toolbox capable of processing BIDS-compatible datasets, singular niftys, points of interests, segmentations, and much more.
Project description
Torso Processing ToolBox (TPTBox)
This is a multi-functional package to handle any sort of bids-conform dataset (CT, MRI, ...) It can find, filter, search any BIDS_Family and subjects, and has many functionalities, among them:
- Easily loop over datasets, and the required files
- Read, Write Niftys, centroid jsons, ...
- Reorient, Resample, Shift Niftys, Centroids, labels
- Modular 2D snapshot generation (different views, MIPs, ...)
- 3D Mesh generation from segmentation and snapshots from them
- Running the Anduin docker smartly
- Registration
- Logging everything consistently
- ...
Install the package
Make venv:
conda create -n 3.10 python=3.10
conda activate 3.10
One of the following:
(you should be in the project folder)
pip install -e ./
or:
Develop mode is really, really nice:
python setup.py develop
sudo python3 setup.py develop
If "python3" don't know where to install, use
which python
sudo <result from which python> setup.py develop
Functionalities
Each folder in this package represents a different functionality.
The top-level-hierarchy incorporates the most important files, the BIDS_files.
BIDS_Files
This file builds a data model out of the BIDS file names.
It can load a dataset as a BIDS_Global_info file, from which search queries and loops over the dataset can be started.
See tutorial_BIDS_files.ipynb
for details.
bids_constants
Defines constants for the BIDS nomenclature (sequence-splitting keys, naming conventions...)
vert_constants
Contains definitions and sort order for our intern labels, for vertebrae, POI, ...
Rotation and Resampling
Example rotate and resample.
# R right, L left .. {"S": "ax", "I": "ax", "L": "sag", "R": "sag", "A": "cor", "P": "cor"}
img_rot = reorient_to(img, axcodes_to=("P", "I", "R"))
img_rot_iso = resample_nib(img_rot, voxel_spacing=(1, 1, 1), order=3, c_val=0)
Snapshot2D
The snapshot function automatically generates sag, cor, axial cuts in the center of a segmentation.
from pathlib import Path
from BIDS.wrapper.snapshot_mr_fun2 import Snapshot_Frame,create_snapshot
ct = Path('Path to CT')
mri = Path('Path to MRI')
vert = Path('Path to Vertebra segmentation')
subreg = Path('Path to Vertebra subregions')
cdt = (vert,subreg,[50]) # 50 is subregion of the vertebra body
# cdt can be also loaded as a json. See definition Centroid_DictList in nii_utils
ct_frame = Snapshot_Frame(image=ct, segmentation=vert, centroids=cdt, mode="CT", coronal=True, axial=True)
mr_frame = Snapshot_Frame(image=mri, segmentation=vert, centroids=None, mode="MRI", coronal=True, axial=True)
create_snapshot(snp_path='snapshot.jpg',frames=[ct_frame, mr_frame])
Snapshot3D
TBD
Docker
TBD
Logger
TBD
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tptbox-0.0.0.tar.gz
.
File metadata
- Download URL: tptbox-0.0.0.tar.gz
- Upload date:
- Size: 3.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a8e083b22f60ed50e30e35d562bfacef78d0b35715eb8b0619917cb7026b00f |
|
MD5 | 299b3ffa70ddbb35dfe2a4cb189cc239 |
|
BLAKE2b-256 | a376462b667bdbe1ae69ad8dee0867efd4be13f9cd5df2a0999d7d4e8b0f19b4 |
File details
Details for the file tptbox-0.0.0-py3-none-any.whl
.
File metadata
- Download URL: tptbox-0.0.0-py3-none-any.whl
- Upload date:
- Size: 3.7 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c01023b4d54cb6296ec8c64a7935ac04528d236e25351f58d56eac56ddd10932 |
|
MD5 | 1f8e479f6d221d29ac7bee330e464114 |
|
BLAKE2b-256 | 1470afe3955396689e671c175a1470f6c965e0a7a30bdb03c1b6a1088285f7bc |