GithubHelp home page GithubHelp logo

Comments (2)

jcreinhold avatar jcreinhold commented on June 25, 2024

I added support for this for Nyul and LSQ. Re-install the package. Make sure your version is v2.0.1.

Fitting and using for arbitrary images is supported in the Python API. For example, you can run:

# load images
import nibabel as nib
image_paths = ["path/to/image1.nii", "path/to/image2.nii", ...]
images = [nib.load(image_path) for image_path in image_paths]

# normalize the images and save the standard histogram
from intensity_normalization.normalize.nyul import NyulNormalize
nyul_normalizer = NyulNormalize()
nyul_normalizer.fit(images)
normalized = [nyul_normalizer(image) for image in images]
nyul_normalizer.save_standard_histogram("standard_histogram.npy")

# load new images and normalize those
new_image_paths = ["path/to/another/image1.nii", "path/to/another/image2.nii", ...]
new_images = [nib.load(image_path) for image_path in new_image_paths]
normalized = [nyul_normalizer(image) for image in images]

# load the standard histogram
new_nyul_normalizer = NyulNormalize()
new_nyul_normalizer.load_standard_histogram("standard_histogram.npy")
normalized = [new_nyul_normalizer(image) for image in images]

For LSQ:

from intensity_normalization.normalize.lsq import LSQNormalize
lsq_normalizer = LSQNormalize()
lsq_normalizer.fit(images)
normalized = [lsq_normalizer(image) for image in images]
lsq_normalizer.save_standard_tissue_means("tissue_means.npy")

# reload the tissue means and use
lsq_normalizer = LSQNormalize()
lsq_normalizer.load_standard_tissue_means("tissue_means.npy")
normalized = [lsq_normalizer(image) for image in images]

RAVEL is only meant to work on a particular batch, so you need to refit it if you add new data to your batch or want to use it to normalize new data.

Similar options are added to the CLI. For nyul-normalize the relevant new options are --save-standard-histogram and --load-standard-histogram. For LSQ, --save-standard-tissue-means and --load-standard-tissue-means.

Let me know if you run into a bug. Reopen the issue if so.

from intensity-normalization.

wjtan99 avatar wjtan99 commented on June 25, 2024

Thanks a lot for your quick response.

from intensity-normalization.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.