Skip to main content

A Torso Processing Toolbox capable of processing BIDS-compatible datasets, singular niftys, points of interests, segmentations, and much more.

Project description

PyPI version tptbox

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

tptbox-0.0.6-py3-none-any.whl (467.6 kB view details)

Uploaded Python 3

File details

Details for the file tptbox-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: tptbox-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 467.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.13

File hashes

Hashes for tptbox-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b6238417a316963b8ebead1de1aebfdd1c8a8cde1432aaac681a38131910bb80
MD5 e5cbeef66e1f64b00dd192688f799dcb
BLAKE2b-256 64ec6f673e9967d638c29f1cd4900c648a57efa0a4c9af6ab9670be2f6c3fd26

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page