Segment kidneys from MRI data
Project description
Renal Segmentor
An application and Python package to segment kidneys from renal MRI data using a convolutional neural network (CNN).
Using the segmentor
The easiest way to make use of the segmentor is to download the windows executable, this allows you to mask data with a stand-alone application. The executable can either be run as a GUI or a command line application allowing it to be integrated into bash scripts.
Alternatively, the methods used by the segmentor are available as a Python package and can be integrated into existing Python pipelines. Instructions for making use of the segmentor via each method are given below.
As a Graphical User Interface (GUI)
- Download the latest release
- Double click
renal_segmentor.exe. The GUI takes quite a long time to load (~30 sec) and doesn't have a splash screen so be patient. - Once the GUI has loaded, click
Browseand select all the raw data you want to segment. You can select multiple files at once. Supported file types are.PAR/.REC,.nii,.nii.gzand.img/.hdr, other file types supported by nibable may work but are untested. - If you want the mask to be just 0s and 1s tick the
binarycheck box, if you want the CNNs probability that the voxel is a kidney, leave it unchecked. - Post-processing can be applied, this discards all but the two largest connected regions in the mask in theory retaining only the two kidneys and removing any erroneous unconnected regions. It should be noted that because post-processing keeps only two regions, care should be taken if using this application with transplant patients as they may have three kidneys.
- Tick the
rawcheckbox if you want the raw image data to be saved as a.nii.gzfile in the same location as the mask (can be useful if you're using.PAR/RECas your input). - If you would like a
.csvfile containing the Total Kidney Volume (TKV), Left Kidney Volume (LKV) and Right Kidney Volume (RKV) for each image that was segmented tick theExport Kidney Volumesbox. - The masks are output from the segmentor as
.nii.gzwith_maskadded to the original file name e.g. the mask ofsub_01.PARissub_01_mask.nii.gz. By default, the mask is output to the same place as the raw data, if you would like the masks to be output to a different directory clickBrowseunderOutput Directoryand select the folder you wish the masks to go to. - Click start.
- The application will run and a few seconds later a box will appear saying the program completed successfully. The first time you run a segmentation will take a little longer as the latest algorithm weights are downloaded from the internet at this point.
- If you want to segment some more data click the
editbutton on the bottom of the finished screen, if you're done, clickclose.
Via a Command Line Interface (CLI)
- Download the latest release
- Run the
renal_segmentor.exe -hto generate a list of available parameters. The application runs via a command line if any input arguments are specified, if not, it opens as a GUI.
As a Python package
- Activate the python environment you want to install the package on and run
pip install renalsegmentor. If you want to install the additional dependencies required for the GUI, runpip install renalsegmentor[gui]however to use the segmentor as a python package, these are not required. - The example code snippet below will generate a mask of
T2w.nii.gzas a numpy array and print the TKV to the terminal.
from segment import Tkv
segmentation = Tkv('T2w.nii.gz')
mask = segmentation.get_mask()
print(f'Total Kidney Volume = {segmentation.tkv:.2f} ml')
Citing Renal Segmentor
If you have made use of renal segmentor for your work, please cite Daniel AJ, et al. Automated renal segmentation in healthy and chronic kidney disease subjects using a convolutional neural network. Magnetic Resonance in Medicine 2021;86:1125–1136 doi: https://doi.org/10.1002/mrm.28768. Alternatively if you wish to cite a specific software version, each release has an individual DOI on Zenodo, the DOI for the latest release can be found here.
How it works
The methods used in this software are outlined in Daniel AJ, et al. Automated renal segmentation in healthy and chronic kidney disease subjects using a convolutional neural network. Magnetic Resonance in Medicine 2021;86:1125–1136 doi: https://doi.org/10.1002/mrm.28768.
Since then the network has been retrained with a larger and more diverse dataset, comprising of 378 subjects with CKD across a range of stages. This dataset was acquired on GE, Philips, and Siemens scanners across nine UK site as part of the AFiRM study. The retrained network shows improved performace over the original version, particularly in subjects with severe renal impairment. The updated network is used as the default in the latest version of Renal Segmentor.
The dataset used to train the original network is freely available on Zenodo, doi: https://doi.org/10.5281/zenodo.5153567.
Contributing
Feel free to open a pull request if you have a feature you want to develop or drop me an email to discuss things further.
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
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 renalsegmentor-2.0.0.tar.gz.
File metadata
- Download URL: renalsegmentor-2.0.0.tar.gz
- Upload date:
- Size: 9.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a357051610c5caedb83aa3c21a5158355ee0bf763e688ccd8edfcff7c97a0d8b
|
|
| MD5 |
03dce38c16b50793e5d410759b56e224
|
|
| BLAKE2b-256 |
4e83965e2d809bfeebe3faec0b491bc0715e884a9d1f2bcc35c9d30df0a1b859
|
File details
Details for the file renalsegmentor-2.0.0-py3-none-any.whl.
File metadata
- Download URL: renalsegmentor-2.0.0-py3-none-any.whl
- Upload date:
- Size: 9.4 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a9385b49d488497ae17e49a6492224888c16f14523b6bd85628200f528a84c0
|
|
| MD5 |
fe03d12ed4e28bb9488e6a0f8b9bf8c4
|
|
| BLAKE2b-256 |
39f6b627a1a1e1c346652043dd4669297dc2093fa60572a30d330d7c54d708be
|