Mirshahi CT Analysis Toolkit (MirCAT). Convert, Segment, and Quantify CT NIfTI files.
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
Mirshahi CT Analysis Toolkit (MirCAT)
A python package designed for rapid analysis of CT images. Convert dicom series to NiFTi, segment body structures, and quantify values within the original image.
Usage
The recommended usage for this repository is directly through the docker image. Use
docker pull idinsmore1/mircat:latest
to get the most recent version. This will easily handle all dependencies, especially with CUDA. MirCAT works with both CPU and GPU for segmentation, but GPU is recommended for the best/fastest results.
If you want a python-based distribution, you can use
pip install mircat # All libraries
pip install mircat-stats # Statistics only library. Useful if you segment on another machine that has CUDA.
No guarantee that dependencies will be easy to solve. In a fresh python environment, it should be fine.
Commands
For docker
docker run idinsmore1/mircat:latest -h
usage: mircat [-h] [-q] {convert,segment,stats,update} ...
Mirshahi CT Analysis Toolkit (MirCAT) CLI tool. Convert dicoms to niftis,
segment niftis, and calculate statistics.
positional arguments:
{convert,segment,stats,update}
convert Convert DICOM files
segment Segment NIfTI files using neural network models
stats Calculate statistics for NIfTI files
update Update the header and stats data for a NIfTI file to
the latest version
options:
-h, --help show this help message and exit
-q, --quiet Decrease output verbosity
For python
# From the command line
mircat -h
# Same output
mircat-copy-models input_dir # This will copy model weights to the proper directory.
Currently the four commands are convert, segment, stats and update.
Convert
This command allows you to convert DICOM series to into NiFTi files. It uses the multiprocessing module for parallelization. The converted NiFTi files will be stored in subfolders in output_dir corresponding to their unique DICOM identifiers.
usage: mircat convert [-h] [-n NUM_WORKERS] [-ax] [-nm] [-th THREADS] dicoms output_dir
positional arguments:
dicoms Path to DICOM files
output_dir Output directory
options:
-h, --help show this help message and exit
-n NUM_WORKERS, --num-workers NUM_WORKERS
Number of workers for converting dicom folders.
-ax, --axial-only Only convert axial dicom series
-nm, --no-mip Do not convert likely mip series
-th THREADS, --threads THREADS
Number of threads for each worker
Segment
This command allows you to segment structrues from NiFTi files. You can specify what tasks you want to run with the --tasks flag. To see the list of outputs for each of the tasks, look at the config file in
in packages/mircat-stats/src/mircat_stats/configs/models.py. Default is to run segmentation on the GPU. If you would like the model weights for these operations please email me at irdinsmore1@geisinger.edu. The docker image will already come with them by default.
If you install with python, you can use mircat-copy-models to copy the directory where you store the model weights to the proper library location.
All segmentations will be stored in a folder next to the give input NiFTi files. For example if I run segment niftis/ex_nifti.nii.gz, the output will be stored in niftis/ex_nifti_segs/ex_nifti_taskname.nii.gz.
usage: mircat segment [-h] [-t TASK_LIST [TASK_LIST ...]] [-th THREADS] [-d DEVICE] [-c CACHE_NUM] [-s SW_BATCH_SIZE] [-n NUM_WORKERS] niftis
positional arguments:
niftis NIfTI file or a text file containing paths to multiple NIfTI files to segment
options:
-h, --help show this help message and exit
-t TASK_LIST [TASK_LIST ...], --task-list TASK_LIST [TASK_LIST ...]
List of segmentation tasks to perform. Default = ["total", "tissues", "body"]
-th THREADS, --threads THREADS
Number of threads to use for multi-threaded operations. Default=4
-d DEVICE, --device DEVICE
Device to use. Default: "cuda:0". Can use "cpu" or "cuda:(other N)"
-c CACHE_NUM, --cache-num CACHE_NUM
the number of niftis to cache at once in RAM. Default=10
-s SW_BATCH_SIZE, --sw-batch-size SW_BATCH_SIZE
Batch size for sliding windows. Default: 4
-n NUM_WORKERS, --num-workers NUM_WORKERS
Number of workers to load imaging data. Default=4
Stats
This command allows you to calculate statistics from the segmented nifti files.
It is recommended to give the same input file that you gave to segment once it has been completed.
If you only want the output from a specific segmentation task, make sure to pass the -t flag to the stats command.
This command will output a statistics json file in the segmentations directory. So if you input example_nifti.nii.gz, then the output will be in example_nifti_segs/example_nifti_stats.json. The output will be ordered in the listed order in packages/mircat-stats/src/mircat_stats/configs/statistics.py if all tasks are ran or --mark-complete flag is used.
The possible tasks to be passed to --task-list are total, contrast, aorta, and tissues.
totalwill give you the total volume and average intensities for all structures segmented from thetotalsegmentation task.contrastwill used a pretrained model to predict the presence of contrast within the CT.aortawill measure the maximum, middle, and proximal diameters of the ascending, arch, descending and abdominal regions of the aorta using a centerline (if they exist in the image).tissueswill measure the total volume and average intensities for the adipose tissues and skeletal muscle from thetissuessegmentation task as well as the areas at the L1, L3, and L5 vertebral levels.- It will also measure body circumference and area at those vertebral levels.
usage: mircat stats [-h] [-t TASK_LIST [TASK_LIST ...]] [-n NUM_WORKERS] [-th THREADS] [-mc] [-g] niftis
positional arguments:
niftis NIfTI file or a text file containing paths to multiple NIfTI files to calculate statistics for
options:
-h, --help show this help message and exit
-t TASK_LIST [TASK_LIST ...], --task-list TASK_LIST [TASK_LIST ...]
List of statistics tasks to perform. Default = ["total", "contrast", "aorta", "tissues"]
-n NUM_WORKERS, --num-workers NUM_WORKERS
Number of workers to use for multi-process operations. Default=1
-th THREADS, --threads THREADS
Number of threads each worker will use. Default=4
-mc, --mark-complete Mark the statistics as complete regardless of stats performed
-g, --gaussian Apply a gaussian smoothing to the label segmentations. Will be slower but more precise upon scaling
Update
This command is usually not needed. Only needs to be used to update the format of the NiFTi header_info.json file when the mircat version changes.
usage: mircat update [-h] [-n NUM_WORKERS] [-th THREADS] niftis
positional arguments:
niftis Path to NIfTI files
options:
-h, --help show this help message and exit
-n NUM_WORKERS, --num-workers NUM_WORKERS
Number of workers
-th THREADS, --threads THREADS
Number of threads
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mircat-1.0.0.tar.gz.
File metadata
- Download URL: mircat-1.0.0.tar.gz
- Upload date:
- Size: 235.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a8a5c455eeb29d014b8c81f2bbb889ec74beb9f5bae4532c3b5d58b9e173e9a
|
|
| MD5 |
2335d79c0e0ac94d8d455fe286da8535
|
|
| BLAKE2b-256 |
e5ec83614c3925f3f3658c2aca90deab5b465a07977d623de093c601c2914c81
|
File details
Details for the file mircat-1.0.0-py3-none-any.whl.
File metadata
- Download URL: mircat-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e73e86d6b2cc47b26e6c65aff8f1cd7523bb94bef0ab88cbd1fdd081b6e5b27
|
|
| MD5 |
2f89647ba39a5de6df1eaf4e97a8925a
|
|
| BLAKE2b-256 |
24e75b93741805045eb27fa4372a7259a1382a56e918e67ae87e8f11e775f497
|