Login  Register

Re: T2* computation...

Posted by Fred Damen on Feb 07, 2020; 4:01am
URL: http://imagej.273.s1.nabble.com/T2-computation-tp5022909p5022923.html

If you are looking to determine a single time constant, then I assume
either the plugin you had found or my plugins, that I selflessly plugged,
should work.  If you are looking to determine two time constants then I do
not know of any existing software specifically for this.  Osirix/Heros
might have something available; as these are DICOM / medical imaging based
kitchen sinc tools.  Writing your own will be challenging unless the time
constants are very different and you have plenty of SNR.  I have attached
a plugin that I just scribbled together that might work. I have not even
tried to compile it, but most of it is cut and pasted from existing code.
Use at your own risk. At least it is a starting point.

Curious, why use GE for this and what are you going to do wtih T2(?) once
determined?

Fred


import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.*;
import ij.plugin.frame.*;

public class T2s_fit implements PlugIn {

   public void run(String arg) {
      ImagePlus imp = IJ.getImage();

      ImagePlus mask = (new
Duplicator()).run(imp,1,1,1,imp.getNSlices(),1,1);
      IJ.run(mask, "32-bit", "");
      IJ.run(mask,"Convert to Mask", "method=Huang background=Default
calculate");
      IJ.run(mask, "Fill Holes", "stack");

      ImagePlus[] pimps = F_Project.compute(imp, new F_Project.Compute() {
           @Override
           public double[] compute(double[] x, double[] y) {
              if (x == null) return new double[4];

              int demarcation = // frame # where faster timeconstant
signal below noise
              double[][] xy = arrSubSet(x,arrln(y),new
int[]{demarcation,x.length-1});
              double mbslow = F_Project.theilsen(xy[0],xy[1]);
              double T2slow = -mbslow[0];
              double S0slow = Math.exp(mbslow[1]);
              xy = arrSubSet(x,arrDiff(y,signal(x,T2slow,S0slow)),new
int[]{0,demarcation});
              double mbfast = F_Project.theilsen(xy[0],xy[1]);
              double T2fast = -mbfast[0];
              double S0fast = Math.exp(mbfast[1]);
              return new double[]{T2slow,T2fast,S0slow,S0fast};

              }
           }, mask, new ImagePlus[0]);

      for(pimp : pimps)
         pimp.show();
      }

   public static double[] signal(double[] ts, double tau, double S0) {
      double[] S = new double[ts.length];
      for(int i=0; i<ts.length; i)
         S[i] = S0*Math.exp(-ts[i]/tau);
      return S;
      }
   public static double[][] arrSubSet(double[] x, double[] y, int[] r) {
      if (r[1]<r[0]) return new double[2][0];
      double[][] ans = new double[2][r[1]-r[0]+1];
      for(int i=0; i<ans[0].length; i++) {
         ans[0][i] = x[i+r[0]];
         ans[1][i] = y[i+r[0]];
         }
      return ans;
      }
   public static double[] arrDiff(double[] a, double[] b) {
      double[] ans = new double[a.length];
      for(int i=0; i<a.length; i++) {
         ans[i] = a[i] - b[i];
         }
      return ans;
      }
   public static double[] arrln(double[] a) {
      double[] ans = new double[a.length];
      for(int i=0; i<a.length; i++) {
         ans[i] = Math.log(a[i]);
         }
      return ans;
      }
}




On Wed, February 5, 2020 2:14 am, Gonzalo Rojas Costa wrote:
> Hi Fred:,
>
> Thanks you very much for your detailed answers...
>
> I have gradient echo images for T2* mapping with 8 equally spaced
different TE values... could you please tell me which imagej plugin or
other software could I use to compute T2 mapping (T2* mapping)?
>
> Sincerely
>
>
> Gonzalo Rojas Costa
>
>
> El mié., 5 de febrero de 2020 02:36, Fred Damen <[hidden email]>
escribió:
>
>> Greetings Gonzalo,
>>
>> If you tell me what you are conceptually trying to accomplish, I could
better guide you.
>>
>> Technically, all MR images are T2* weighted, as R2* (1/T2*) is the
observed rate at which the MR signal attenuates due to the spins
dephasing. Using a spin-echo sequence, the spins dephased by deltaB0 are
rephased during image acquisition window and thus eliminates the T2'
information from the image; thus making spin-echo the acquisition method
of choice for T2 mapping.  If using a gradient echo sequence is a
requirement, then I assume that you can acquire enough images with
properly spaced TE(s) such that you can do a bi-exponential fit to extract

>> both T2 and T2'.  Although note, that deltaB0 causes
>> blurring/displacement
>> in addition to signal attenuation.
>>
>> Enjoy,
>>
>> Fred
>>
>> On Mon, February 3, 2020 2:53 pm, Gonzalo Rojas Costa wrote:
>> > Hi Fred:
>> >
>> > For T2* mapping I mean T2 mapping for gradient echo sequence...
>> >
>> > Sincerely,
>> >
>> >
>> > Gonzalo Rojas Costa
>> >
>> >
>> > El lun., 3 de febrero de 2020 21:06, Fred Damen <[hidden email]>
escribió:
>> >
>> >> Greetings,
>> >>
>> >> It depends on what exactly what you mean by T2* mapping?
>> >>
>> >> If you are referring to determining the time constant then the same
>> post
>> >> processing plugin will work.  1/T2* = 1/T2 + 1/T2'; A spin echo
pulse sequence eliminates, i.e, reduces to negligible level, the T2'
>> component
>> >> leaving just the T2 component.  A gradient echo sequence includes
the T2'
>> >> component.
>> >>
>> >> If you are referring to creating deltaB0 map, then you need to do a
linear

>> >> fit to the phase image, albeit with special handling of the phase
>> wrap.
>> >> I
>> >> have a plugin for this. (I have not yet dressed the code up for
>> release
>> >> though)
>> >>
>> >> If you are referring to Susceptibility Weighted Imaging, I do not
>> know
>> >> of
>> >> a ImageJ plugin, albeit there are other tools out there.
>> >>
>> >> Enjoy,
>> >>
>> >> Fred
>> >>
>> >> On Mon, February 3, 2020 12:44 pm, Gonzalo Rojas Costa wrote:
>> >> > Hi:
>> >> >
>> >> >   Which plugin computes T2* mapping ?.. Because "MRI Analysis
>> >> Calculator
>> >> > v1.0" only computes T2 mapping...
>> >> >
>> >> >   Sincerely,
>> >> >
>> >> >
>> >> > Gonzalo Rojas Costa
>> >> > Chair LABMAN (OHBM)
>> >> >
>> >> > Laboratory for Advanced Medical Image Processing
>> >> > Department of Radiology
>> >> > Health Innovation Center
>> >> > Clínica las Condes
>> >> > Lo Fontecilla 441, Las Condes, Santiago, Chile.
>> >> > Tel: 56-2-2105170
>> >> > Cel: 56-9-97771785
>> >> > http://www.aribrain.info
>> >> > https://scholar.google.com/citations?user=LO7LZ3oAAAAJ
>> >> > https://www.researchgate.net/profile/Gonzalo_Rojas2
>> >> > http://www.researcherid.com/rid/B-2036-2013
>> >> > https://cl.linkedin.com/in/gonzalorojascosta
>> >> >
>> >> > --
>> >> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>> >> >
>> >>
>> >> --
>> >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>> >>
>> >
>> > --
>> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>> >
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html