Skip to content

v1.1.0

Compare
Choose a tag to compare
@JoostJM JoostJM released this 22 Feb 22:03
· 716 commits to master since this release

Implementation of C Extensions

Stats:

Profiling 5 testcases using python 2.7

  • GLCM 6913 ms -> 3 ms
  • GLSZM 12064 ms -> 58 ms
  • GLRLM 1850 ms -> 10 ms
  • Surface Area 3241 -> 1 ms

Code:

  • _cmatrices: C implementation for matrix computation associated with GLCM, GLSZM and GLRLM features.
  • _cshape: C implementation for Shape surface computation.
  • tests/test_cmatrices: testing for matrix equality: Tests whether the python generated matrix is equal to the matrix generated by the C implementations (allows for machine precision errors). Also compares the python and C generated surface computations similarly.

Details

  • Standardize function names for calculating matrices in python and with C extensions to _calculateMatrix and _calculateCMatrix, respectively.
  • Add docstring to C modules.
  • Use of C implementation optional. At initialization, the package tries to use C, but if loading has failed, or calculation is forced to python, python is used. Note that the import of _cmatrices is done after initialization of logger. This ensures error will be logged if import fails. This can be controlled through the enableCExtensions setting, which can be provided in a parameter file or as part of the kwargs dictionary in featureextractor.
  • GLSZM: Use "char" datatype for mask. (It is signed char in GLSZM).
  • C code is consistent with C89 convention. All variables (pointers for python objects) are initialized at top of each block.
  • GLSZM: Use calloc and free for the temporary array holding the calculated zones.

Optimizations

  • GLSZM:
    • Define temporary array for holding the calculated zones. During calculation, the matrix must be able to store all possible zones, ranging from zone size 1 to total number of voxels (Ns), for each gray level (Ng). In this case, the GLSZM would be initialized with size Ng * Ns, which is very memory intensive. Instead, use a temporary array of size (Ns * 2) + 1, which stores all calculated zones in pairs of 2 elements: the first element holds the gray level, the second the size of the calculated zone. The first element after the last zone is set to -1 to serve as a stop sign for the second function, which translates the temporary array into the final GLSZM, which can be directly initialized at optimum size.
    • Uses "while" loops. This allows to reduce the memory usage. We observed that with recursive functions it was 'unexpectedly' failing.
    • Optimized search that finds a new index to process in the region growing.

Associated issues: #106

Associated PRs: #158, #200, #202

Python 3 Compatibility:

  • As of this version, PyRadiomics is compatible with python 2.7 and python >= 3.4. This is acchieved through use of third-party package six (added to requirements.txt). The changes to ensure this compatibility do not change the user interface.

Associated issues: #178, #204

Associated PRs: #188, #194, #196, #205

Normalization

  • Add functionality to imageoperations for normalizing image intensity values. If enabled, the image is normalized by centering it at the mean with standard deviation. Normalization is based on all gray values in the image, not just those inside the segementation. It is enabled or disabled by setting the parameter normalize.
  • Values can be scaled using parameter normalizeScale, which multiplies the normalized intensity values by the value of this paramter.
  • Outliers can be removed by setting the removeOutliers parameter. If set, all values differing more than n * (standard deviation) from the mean are set to n * (standard deviation), where n is equal to the value of this parameter. This is done after normalizing and before applying the scale. If this last parameter is omitted, no outliers are removed.
  • If enabled, normalization is applied after loading the image, before any resampling or application of filters.

Associated PRs: #209

Parameterization:

  • Add parameter for controlling the additional output (enable/disable by setting additionalInfo parameter)
  • Add parameter for controlling whether or not to calculate in full-python mode (enable/disable by setting enableCExtensions parameter).

Associated PRs: #190, #202

Documentation:

  • Documentation on installation and usage is upgraded, with the addition of an embedded instruction video (in section "Usage", cued at the section on usage examples).
  • Updated contact information to point to the google groups.
  • Updated the classifiers in the setup script to reflect the more advanced status of Pyradiomics.
  • The version specific documentation is available here.

Associated PRs: #187, #193

Continuous Testing:

Upgrade to include other python versions and platforms

  • Tests are passed for Linux, Windows and Mac, using python 2.7, 3.4 and 3.5, in 32- and 64-bit builds.

Associated PRs: #183, #191, #199

Style:

  • Testing output is upgraded to ensure unique feature names.
  • getFeatureClasses() and getInputImageTypes() functions are moved from featureextractor to global radiomics namespace. This enumerates the possible feature classes and filters at initialization of the toolbox, and ensures feature classes are imported at initialization.

Associated PRs: #190, #195, #197, #198