Giter VIP home page Giter VIP logo

itkioscanco's Introduction

ITKIOScanco

Build, test, package

Notebooks tests

PyPI Version

License

image

Overview

An ITK module to read and write Scanco microCT .isq files.

This package is a resource created by Kitware et. al. for the community for Open and Reproducible Musculoskeletal Imaging Research (ORMIR).

ITK is an open-source, cross-platform library that provides developers with an extensive suite of software tools for image analysis. Developed through extreme programming methodologies, ITK employs leading-edge algorithms for registering and segmenting multidimensional scientific images.

ITKIOScano Notebook

Installation

Python

Binary Python packages are available for Linux, macOS, and Windows. They can be installed with:

python -m pip install --upgrade pip
python -m pip install itk-ioscanco

C++

Build the module as a separate project against an ITK build tree:

git clone https://github.com/KitwareMedical/ITKIOScanco
mkdir ITKIOScanco-build
cd ITKIOScanco-build
cmake -DITK_DIR=/your/path/to/ITK-build ../ITKIOScanco
cmake --build .

Alternatively, since ITK 5.0, the module can be built by enabling the option:

Module_IOScanco:BOOL=ON

in ITK's CMake configuration.

Usage

import itk

image = itk.imread('myvolume.ISQ')

License

This software is distributed under the Apache 2.0 license. Please see the LICENSE file for details.

itkioscanco's People

Contributors

dependabot[bot] avatar dzenanz avatar hjmjohnson avatar jhlegarreta avatar mkuczyns avatar mseng10 avatar tbirdso avatar thewtex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

itkioscanco's Issues

Reading .ISQ header

Hi,

Is there a function that reads and returns the header of .isq files?

Thanks!
Serena

Is compressed data subject to rescaling?

Currently, rescaling is done only if input image is not compressed:

if (this->m_RescaleSlope != 1.0 || this->m_RescaleIntercept != 0.0)
{
switch (dataType)
{
case IOComponentEnum::CHAR:
RescaleToHU(reinterpret_cast<char *>(buffer), bufferSize, this->m_RescaleSlope, this->m_RescaleIntercept);
break;
case IOComponentEnum::UCHAR:
RescaleToHU(
reinterpret_cast<unsigned char *>(buffer), bufferSize, this->m_RescaleSlope, this->m_RescaleIntercept);
break;
case IOComponentEnum::SHORT:
bufferSize /= 2;
RescaleToHU(reinterpret_cast<short *>(buffer), bufferSize, this->m_RescaleSlope, this->m_RescaleIntercept);
break;
case IOComponentEnum::USHORT:
bufferSize /= 2;
RescaleToHU(
reinterpret_cast<unsigned short *>(buffer), bufferSize, this->m_RescaleSlope, this->m_RescaleIntercept);
break;
case IOComponentEnum::INT:
bufferSize /= 4;
RescaleToHU(reinterpret_cast<int *>(buffer), bufferSize, this->m_RescaleSlope, this->m_RescaleIntercept);
break;
case IOComponentEnum::UINT:
bufferSize /= 4;
RescaleToHU(
reinterpret_cast<unsigned int *>(buffer), bufferSize, this->m_RescaleSlope, this->m_RescaleIntercept);
break;
case IOComponentEnum::FLOAT:
bufferSize /= 4;
RescaleToHU(reinterpret_cast<float *>(buffer), bufferSize, this->m_RescaleSlope, this->m_RescaleIntercept);
break;
default:
itkExceptionMacro("Unrecognized data type in file: " << dataType);
}
}

Should this be done in case of compression? If so, we should move the rescaling block from line 1126 to the end of the method, just after delete[] input; (currently on line 1294).

installing itk-ioscanco is not working

Hallo everyone,

i am trying to install itk-ioscanco in order to read ISQ image, I have python 3.9 and tried to install ioscanco through
python3 -m pip install itk-ioscanco
but I always get this error:
ERROR: Could not find a version that satisfies the requirement itk-ioscanco (from versions: none)
ERROR: No matching distribution found for itk-ioscanco
can anyone help with this thank you!

crashes at call

Hi,
Saw that you wrapped the module to python,
tried to test it crashes at call :

conda create --name itk  python=3.5
conda activate itk 
conda install numpy pip ipython
pip install itk itk-ioscanco

ipython
import itk
reader = itk.ScancoImageIO.New()

then it crashes IPython without any warning :(

Attempting to build RemoteModule results in failure due to missing object download

CMake Error at /Shared/sinapse/opt/iiai/apps/cmake/3.15.0/share/cmake-3.15/Modules/ExternalData.cmake:1121 (message):

Object
SHA512=9f03a48869d8b4ced44927a273f95f4d9985a644206145ff6580892242a42081c51865013cfc490c011a7a765dcf6764d98bee92da718829faa177e5540de211
not found at:

https://insightsoftwareconsortium.github.io/ITKTestingData/SHA512/9f03a48869d8b4ced44927a273f95f4d9985a644206145ff6580892242a42081c51865013cfc490c011a7a765dcf6764d98bee92da718829faa177e5540de211 ("HTTP response code said error")
https://data.kitware.com:443/api/v1/file/hashsum/SHA512/9f03a48869d8b4ced44927a273f95f4d9985a644206145ff6580892242a42081c51865013cfc490c011a7a765dcf6764d98bee92da718829faa177e5540de211/download ("Timeout was reached")
https://itk.org/files/ExternalData/SHA512/9f03a48869d8b4ced44927a273f95f4d9985a644206145ff6580892242a42081c51865013cfc490c011a7a765dcf6764d98bee92da718829faa177e5540de211 ("HTTP response code said error")
https://slicer.kitware.com/midas3/api/rest?method=midas.bitstream.download&checksum=9f03a48869d8b4ced44927a273f95f4d9985a644206145ff6580892242a42081c51865013cfc490c011a7a765dcf6764d98bee92da718829faa177e5540de211&algorithm=SHA512 (wrong hash SHA512=639526ba1271b833beeb026311a3d40d2b50b8480ce8e938e87ea0dfc9c84e76867be09043f9b15fc5b21d003580c6169f1ba59b2202686b80258d8993ab7a09)

Reading *.AIM contours fails

When reading contours generated by Scanco (*.AIM) the following error is prompted:

TemplateTypeError: itk.Image is not wrapped for input type itk.SC, int.
Would it be possible to cast these images to a different type? They typically only contain a binary classification for the trabecular/cortical contours.

Metadata partly deleted when writing .ISQ

Hi,

i noticed that when opening an .ISQ file and then writing it as an .ISQ file, parts of the metadata seem to get deleted, or changed.
It seems to be affecting the CalibrationData, CreationDate, ModificationDate, MuScaling, MuWater, RescaleIntercept, RescaleSlope, RescaleType and RescaleUnits.

Here is an example of the code:

import itk
image=itk.imread('original_file.ISQ')
print(dict(image))
itk.imwrite(image,'saved_file.ISQ')
image_saved=itk.imread('saved_file.ISQ')
print(dict(image_saved))

Output for the original file:

{'CalibrationData': '60 kVp, BH: 200 mg HA/ccm, Scaling 8192', 'CreationDate': '14-JUN-2021 13:27:50.972', 'DataRange': (-5135.0, 11000.0), 'Energy': 59.4, 'Intensity': 0.9, 'MeasurementIndex': 24945, 'ModificationDate': '14-JUN-2021 13:27:50.972', 'MuScaling': 8192.0, 'MuWater': 0.2402999997138977, 'NumberOfProjections': 750, 'NumberOfSamples': 1536, 'PatientIndex': 3453, 'PatientName': 'Anonymous', 'ReconstructionAlg': 3, 'ReferenceLine': 0.0, 'RescaleIntercept': -1000.0, 'RescaleSlope': 0.5079913135469725, 'RescaleType': 2, 'RescaleUnits': 'mg HA/ccm', 'SampleTime': 100.0, 'ScanDistance': 125.952, 'ScannerID': 3333, 'ScannerType': 9, 'Site': 39, 'SliceIncrement': 0.08199999999999999, 'SliceThickness': 0.08199999999999999, 'Version': 'CTDATA-HEADER_V1', 'origin': array([0., 0., 0.]), 'spacing': array([0.082, 0.082, 0.082]), 'direction': array([[1., 0., 0.],
       [0., 1., 0.],
       [0., 0., 1.]])}

Output for the written file:

{'CalibrationData':` '', 'CreationDate': '6-DEC-1911 13:07:54.671', 'DataRange': (-5135.0, 11000.0), 'Energy': 59.4, 'Intensity': 0.9, 'MeasurementIndex': 24945, 'ModificationDate': '6-DEC-1911 13:07:54.671', 'MuScaling': 1.0, 'MuWater': 0.7032999992370605, 'NumberOfProjections': 750, 'NumberOfSamples': 1536, 'PatientIndex': 3453, 'PatientName': 'Anonymous', 'ReconstructionAlg': 3, 'ReferenceLine': 0.0, 'RescaleIntercept': 0.0, 'RescaleSlope': 1.0, 'RescaleType': 0, 'RescaleUnits': '', 'SampleTime': 100.0, 'ScanDistance': 125.952, 'ScannerID': 3333, 'ScannerType': 9, 'Site': 39, 'SliceIncrement': 0.08199999999999999, 'SliceThickness': 0.08199999999999999, 'Version': 'CTDATA-HEADER_V1', 'origin': array([0., 0., 0.]), 'spacing': array([0.082, 0.082, 0.082]), 'direction': array([[1., 0., 0.],
       [0., 1., 0.],
       [0., 0., 1.]])}

Is there maybe a solution for this?

Thanks for any help in advance and thanks for providing this tool!

Meta data conversion to density

I have a problem converting loaded AIMs to density

after reading an aim file (XCT 1), the image data is in hounsfield units. I seem to be missing the density intercept and density slope. Is there any way these can be added to the meta data? Thank you for your help!

{'CalibrationData': '60kVp, BH: 200 mg HA/ccm, Scaling 8192',
 'CreationDate': 'XXXXXX', #blinded
 'DataRange': (-1314.0, 10451.0),
 'Energy': 59.4,
 'Intensity': 0.9,
 'MeasurementIndex': 0000, #blinded
 'ModificationDate': 'XXXXX', #blinded
 'MuScaling': 8192.0,
 'MuWater': 0.2415,
 'NumberOfProjections': 750,
 'NumberOfSamples': 1536,
 'PatientIndex': 0000, #blinded
 'PatientName': 'XXXXXX', #blinded
 'ReconstructionAlg': 3,
 'ReferenceLine': 0.0,
 'RescaleIntercept': -1000.0,
 'RescaleSlope': 0.505467132505176,
 'RescaleType': 2,
 'RescaleUnits': 'mg HA/ccm',
 'SampleTime': 100.0,
 'ScanDistance': 125.952,
 'ScannerID': 3330,
 'ScannerType': 9,
 'Site': 20,
 'SliceIncrement': 0.0820000022649765,
 'SliceThickness': 0.0820000022649765,
 'Version': 'AIMDATA_V020   ',
 'origin': array([ 0.        , 51.65999985, 46.49399948]),
 'spacing': array([0.082, 0.082, 0.082]),
 'direction': array([[1., 0., 0.],
        [0., 1., 0.],
        [0., 0., 1.]])}

itk.Image is not wrapped for input type `itk.SC, int`

Hello,

I attempted to use ITKIOScanco to open segmentation masks in *.AIM format. These only contain two values, 0 and 1, and are encoded in signed char (afaik). On trying to open, I received the following error (full stack trace attached below):

TemplateTypeError: itk.Image is not wrapped for input type itk.SC, int.

After some digging, I found a possible solution would be to set the ComponentType, as follows:

itk.ScancoImageIO.New(ComponentType=itk.CommonEnums.IOComponent_SHORT)

however, this change is not passed through, and I still receive the same error. Finally, I was able to mitigate the error by editing _io_component_type_dict in the file itk/support/template_class.py on Line 179 to read

"char": itk.SS,

Formerly, this line read

"char": itk.SC,

which fixed the above mentioned error, but I do not find this solution satisfactory. Unfortunately, I do not have full debugging capabilities on my setup (using Jupyter), so I am unable to follow up where exactly the ComponentType is overwritten, however I can verify that after calling itk.imread(), the property is set back to char, even if I explicitly set it to short before.

Any suggestions or help with this issue are strongly appreciated, as I would prefer a "clean" solution to this problem.

For reference, I am using Anaconda3 on Ubuntu 22.04.1 LTS. The installed library versions are

itk                       5.2.1.post1
itk-bonemorphometry       1.3.0
itk-core                  5.2.1.post1
itk-filtering             5.2.0
itk-io                    5.2.1.post1
itk-ioscanco              0.9.2
itk-meshtopolydata        0.8.1
itk-numerics              5.2.1.post1
itk-registration          5.2.1.post1
itk-segmentation          5.2.1.post1
itk-texturefeatures       3.5.1

Sample files and code examples can be submitted on request.

Full stacktrace: stacktrace_itkioscanco.txt

Thank you, and keep up the good work!

Best regards,
Johannes

PS: I use ITKIOScanco regularly to read SCANCO *.AIM volume files in Python, and it works exactly as expected. The problem only occurs with segmentation masks, which are generated from GOBJ-files and often referred to as *seg.aim-files by SCANCO.

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.