Normalising XY data by Z-direction in stacks

Posted by Thomson Neil (EAST KENT HOSPITALS UNIVERSITY NHS FOUNDATION TRUST) on
URL: http://imagej.273.s1.nabble.com/Normalising-XY-data-by-Z-direction-in-stacks-tp3685096p3685098.html

Hi James

I don't know your background, so forgive me if I'm way off the mark...

This should be a pretty trivial problem with some coding. If you haven't looked at the developer<http://rsbweb.nih.gov/ij/developer/index.html> section of he ImageJ website, have a look now. If you've never done any programming then writing a Java plugin might be a bit scary, but the macro language <http://rsbweb.nih.gov/ij/developer/macro/macros.html> should so the trick.

This macro-code snippet might give you an idea on normalisation:

// Make sure image accepts floating point values
run("32-bit");
// get image width x
// get image height y
// get image depth z
for (i=0; i < x; i++){
  for (j=0; i < y; j++){
    // Get max value in the x-y coord
    maxValue = 0;
    for (k=0; i < z; k++){
      setSlice(k);
      currValue = getPixel(x, y);
      if (currValue > maxValue){
        maxValue = currValue;
      }
    }
    // Set new value normalised to max value
    for (k=0; i < z; k++){
      setSlice(k);
      setValue(x, y, getPixel(x, y)/maxValue);
    }
  }
}

Neil

Neil Thomson,
Nuclear Medicine Physics Section,
Medical Physics,
Kent and Canterbury Hospital,
UK. CT1 3NG
+44 (0) 1227 766877

********************************************************************************************************************

This message may contain confidential information. If you are not the intended recipient please inform the
sender that you have received the message in error before deleting it.
Please do not disclose, copy or distribute information in this e-mail or take any action in reliance on its contents:
to do so is strictly prohibited and may be unlawful.

Thank you for your co-operation.

NHSmail is the secure email and directory service available for all NHS staff in England and Scotland
NHSmail is approved for exchanging patient data and other sensitive information with NHSmail and GSi recipients
NHSmail provides an email address for your career in the NHS and can be accessed anywhere
For more information and to find out how you can switch, visit www.connectingforhealth.nhs.uk/nhsmail

********************************************************************************************************************