Skip to content

Collection of functions for medical image pre-processing and deep learning

Notifications You must be signed in to change notification settings

nki-radiology/Frida

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub

Frida

Frida results as a collection of different functions and procedures for medical image analysis that used and re-used during my PhD.

Getting Started

Dont install with pip, but rather:

git clone https://github.com/nki-radiology/Frida
cd Frida
pip install -e .

Dependencies

Frida requires

  • Python (>=3.6)
  • NumPy (>=1.19)
  • SciPy (>=1.5.2)
  • SimpleITK (>=2.0)
  • SciKit-Image (>=0.17.2)

Older packages might still work, but not guaranteed.

Usage

Frida is written to be a modular package to design pipelines for medical image processing. With that in mind, there are three main operations/modules that you can find in frida:

  • a Read operator, which takes in input a physical location and returns a SimpleITK.Image;
  • a Transform operator, which takes in input a SimpleITK.Image and returns a SimpleITK.Image;
  • a Pipeline operator, which is defined as a set of operations to be executed sequentially.

Here is an example of these

from frida import Pipeline
from frida.readers ReadDICOM
from frida.transforms import PadAndCropTo, Resample

my_pipeline = Pipeline(
    ReadDICOM(),
    Resample((2., 2., 1.), cval=0),
    PadAndCrop((160, 160, 160), cval=0)
)

image = my_pipeline(r'path/to/image/nrrd_or_dicom')

This pipeline reads a DICOM image, resamples it to anisotropic voxel size 2x2x1 units (mm, most likely), and applies pad and cropping operations to bring the size of the image to a cube of size 160 voxels.

There are two additional types of Transform operators with special functions:

  • a Cast operator, which takes in input a SimpleITK.Image and returns a format defined by the user;
  • a Augemtation operator, which applies a transform operator to the image with a random component in it.

Here is an example of a pipeline using them

from frida import Pipeline
from frida.readers import ReadDICOM
from frida.transforms import PadAndCropTo

from frida.augmentations import RandomLinearDisplacement
from frida.cast import ToNumpyArray

my_pipeline = Pipeline(
    ReadDICOM(),
    PadAndCrop((160, 160, 160)),
    RandomLinearDisplacement(rotation_range=10, zoom_range=0.5),
    ToNumpyArray(add_batch_dim=True, add_singleton_dim=False)
)

image_arr = my_pipeline(r'path/to/image/nrrd_or_dicom')
print(image_arr.shape)

>> (1, 160, 160, 160)

More can be found on the documentation!

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

About

Collection of functions for medical image pre-processing and deep learning

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages