Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring #1

Open
schuhschuh opened this issue Dec 10, 2017 · 4 comments
Open

Refactoring #1

schuhschuh opened this issue Dec 10, 2017 · 4 comments
Assignees
Milestone

Comments

@schuhschuh
Copy link
Member

schuhschuh commented Dec 10, 2017

Refactor Christian's MALPEM package to make it a MIRTK extension package which uses MIRTK commands instead of deprecated IRTK binaries.

MIRTK replacements

  • seg_maths (NiftySeg): mirtk.calculate_element_wise
    • -bin: use (current image>0) to binarise
      • seg_maths image.nii -bin mask.nii
      • mirtk.calculate_element_wise('image.nii', '-threshold-le', 0, '-pad', 0, '-set', 1, '-out', 'mask.nii')
    • -thr
    • -uthr
    • -mul
    • -add
    • -sub
    • -div
  • cl_create4D: mirtk.combine_images
  • cl_pairwiseSymDOF: mirtk.average_dofs
  • cl_apply_mask
    • mirtk.calculate_element_wise('scan.nii', '-mask', 'mask.nii', '-pad', -1, '-out', brain.nii')
  • convert: mirtk.convert_image
  • cl_extract_frame: mirtk.extract_image_volume
  • cl_averageDOFs: mirtk.average_dofs
  • dofinvert: mirtk.invert_dof
  • dofcombine: mirtk.compose_dofs
  • ireg: mirtk.register
  • transformation: mirtk.transform_image
  • display: Use mirtk.rendering.screenshots module for report generation.

Custom tools

  • cl_compute_volume: Consider adding this to core MIRTK applications
  • cl_gaussian_fusion
  • cl_malpem
  • cl_malpem4D
  • pincram-0.2.3_ireg.sh (see below)
  • scale.sh (see below)

External dependencies

  • N4 (also used by Draw-EM package, see here... though binary shouldn't be in repo)
@schuhschuh schuhschuh self-assigned this Dec 10, 2017
@schuhschuh schuhschuh changed the title MALPEM refactoring Refactoring Dec 10, 2017
@schuhschuh schuhschuh added this to the v2.0 milestone Dec 10, 2017
@schuhschuh
Copy link
Member Author

schuhschuh commented Dec 10, 2017

PINCRAM script:

  • ireg: mirtk register
  • seg_maths operations: -div, -thr, -bin: mirtk calculate-element-wise
  • dofcombine: mirtk compose-dofs
  • transformation: mirtk transform-image
  • headertool
    • -origin <x> <y> <z>
    • mirtk edit-image a.nii.gz b.nii.gz -origin <x> <y> <z>
  • convert to -float: mirtk convert-image in.nii out.nii -float
  • dilation: mirtk dilate-image
  • erosion: mirtk erode-image
  • subtract: mirtk calculate-element-wise a.nii -sub b.nii -out a_minus_b.nii
  • padding
  • labelStats
  • evaluation: evaluation emasked-$thislevel.nii.gz $srctr -Tp 0 -mask emargin-$thislevel-dil.nii.gz -linear | grep NMI | cut -d ' ' -f 2

@schuhschuh
Copy link
Member Author

schuhschuh commented Dec 10, 2017

scale.sh:

  • seg_stats (NiftySeg) options (see here):
    • -t 1: Only estimate statistics if voxel is larger than 1
    • -R: The robust range (assuming 2% outliers on both sides) of all voxels
    • mirtk calculate-element-wise img.nii -threshold 1 -pct 2 98 -d ' '
  • seg_maths (NiftySeg) operations: -thr, -bin, -mul, -uthr, -add
$maths_ms $input_ms -thr $max_ms -bin -mul 255 $peaks_ms

fac_ms=$(echo "scale=5; 255/$max_ms" | /usr/bin/bc)
echo $fac_ms

$maths_ms $input_ms -mul $fac_ms -uthr 255 -add $peaks_ms $output_ms
$maths_ms $output_ms -thr 257 -bin -mul 255 $peaks_ms
$maths_ms $output_ms -uthr 256 -add $peaks_ms $output_ms

$maths_ms $input_ms -uthr 0 -mul -1 -bin -mul -1 $tmp_ms
$maths_ms $output_ms -thr 0 -add $tmp_ms $output_ms
  • cl_erosion (5 iterations):
    • Input is grey-scale image
    • Binarise by setting values >0 to one and zero otherwise
    • Erode this binary mask
    • Set all input grey-scale values outside of mask to zero, keep other values unchanged

@schuhschuh
Copy link
Member Author

myProbabilisticAtlas adds SwapImages function, which is also in Draw-EM's implementation.

@schuhschuh
Copy link
Member Author

schuhschuh commented Dec 12, 2017

To-Do list

  1. Remove proot script.
  2. Refactor PINCRAM Bash script:
    • Move common functions directly inside pincram script.
    • Use mirtk calculate-element-wise instead of seg_maths.
    • Any replacement for labelStats available? How about mirtk evaluate-overlap?
      • Usage: labelStats ref.nii.gz assess.nii.gz -q | cut -d ',' -f 1
      • -q: Quiet summary, CSV output: OR,Dice (mean values over all labels)
      • Add -mean option or similar to evaluate-overlap command.
  3. Refactor C++ implementation of required custom commands:
  4. Refactor MALPEM Python modules:
  5. Update installer script.
  6. Update README and LICENSE.
  7. Include package in main MIRTK repository as optional extension package (Git submodule).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant