CoBrALab / minc-bpipe-library

Library of bpipe implemented commands commonly applied to minc datafiles, suitable for importing into other pipelines
Other
13 stars 8 forks source link

Target operations #1

Closed gdevenyi closed 9 years ago

gdevenyi commented 9 years ago

Current understanding of "best" order of operations is: denoise -> n3/n4correct -> normalize

gdevenyi commented 9 years ago

nu_correct -verbose -clobber -distance -iter 200 -shrink 2 -stop 0.000001 -fwhm 0.15 -distance 30 $input.mnc $output.mnc http://www.ncbi.nlm.nih.gov/pubmed/19559796 for -distance

gdevenyi commented 9 years ago

This runs mincnlm which is the original "non local means" filter for rician noise http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=4359947

volume_denoise.pl $input.mnc $output.mnc --verbose --clobber Applies checks for iso or ansio resolution and runs nonlocal means filter

gdevenyi commented 9 years ago

There is also an "adaptive non local means" which is improved and probably should probably be used http://onlinelibrary.wiley.com/doi/10.1002/jmri.22003/full

minc_anlm $input.mnc $output.mnc

gdevenyi commented 9 years ago

N4BiasFieldCorrection is an much improved implementation of n3 using non-uniform bsplines N4BiasFieldCorrection -b [200] -c [200x200x200x200,0.0000000001] -i $input.mnc -o $output.mnc

http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=5445030

gdevenyi commented 9 years ago

Beast Stages from mincbeast_bpipe:

TEMPLATE_DIR="/data/chamal/projects/raihaan/templates"
LIBRARY_DIR="/data/chamal/projects/raihaan/BEaST_libraries/ADNI_library"

//Beastnormalize, don't perform n3 because it's already been done
beastnormalize = {
    branch.origname = "$input"
    exec "beast_normalize $input.mnc $output.mnc $output.xfm -non3 -modeldir $TEMPLATE_DIR"
}

beastmask = {
    exec "mincbeast -clobber -verbose $LIBRARY_DIR $input.mnc $output.mnc -fill -median -nlm_filter -same_res -conf $LIBRARY_DIR/default.1mm.conf"
}

beastresample = {
    from("xfm", "mnc") {
        exec "mincresample -invert_transformation -like $origname -transformation $input.xfm $input.mnc $output.mnc"
    }
}

beastextract = {
    exec "minccalc -expression A[0]*A[1] $origname $input.mnc $output.mnc"
}

beast = segment {
    beastnormalize + beastmask + beastresample + beastextract
}
gdevenyi commented 9 years ago

Dumb-normalize

Options

top and bottom 1% of voxels

top and bottom 1% of intensity

Issue: what to do about scaling range, don't want to lose dynamic range of data

Probably should scale data to maximum of the data format (0 -> 16bit or 0 -> 32bit)

dumb_normalize = {
    //Performs a dumb normalization of the data, throwing away top and bottom 1% and then scaling 0 to 65535
    //Requires minc-toolkit
    exec """
    minccalc -2 -clobber -expression "A[0]<(0.01*\$(mincstats -quiet -max $input.mnc)) || A[0]>(0.99*\$(mincstats -quiet -max $input.mnc)) ? 0 : A[0]" $input.mnc $output.tmp
    """
    exec """
    minccalc -2 -short -unsigned -clobber -expression "A[0]/\$(mincstats -quiet -max $output.tmp)*65535" $output.tmp $output.mnc
    """
}
mallarchak commented 9 years ago

Scale to 1024? That should the job, shouldn't it?

On Wed, Nov 5, 2014 at 9:38 AM, Gabriel A. Devenyi <notifications@github.com

wrote:

Dumb-normalize

Options

top and bottom 1% of voxels

  • mincstats -histogram
  • Find bottom 1% (bin 20)
  • Find top 1% (bin 1980)
  • Scale bottom and below to zero
  • Scale top and above to ???

top and bottom 1% of intensity

  • Find max value
  • 1% bottom cutoff
  • 99% top cutoff
  • Scale bottom and below to zero
  • Scale top and above to ???

Issue: what to do about scaling range, don't want to lose dynamic range of data

Probably should scale data to maximum of the data format (0 -> 16bit or 0 -> 32bit)

— Reply to this email directly or view it on GitHub https://github.com/CobraLab/bpipe-library/issues/1#issuecomment-61815891 .

gdevenyi commented 9 years ago

The problem is that I've seen lots of raw images with values of 0 to >1024, if I clamp to 1024, we could be losing dynamic range.

raihaan commented 9 years ago

its late, so i might be missing it - but looks like resampling both masks and extracted brains to native space is missing from beast stages, we should add.

i believe

mincresample -like nativeimage.mnc -transformation MNI_register_inverse.xfm *beastmask.mnc nativemask.mnc 

should do the trick

gdevenyi commented 9 years ago

What exactly are the relevant outputs for beast, the mask and brain in MNI space or the mask and brain in native space?

raihaan commented 9 years ago

I'd say the native mask and native brain are the final outputs - this was the step before extraction in our original BEaST how to:

https://github.com/CobraLab/documentation/wiki/How-to-run-BEaST