Transpose Table in Image J help

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Transpose Table in Image J help

Jacob Lewis
Hi All,

I am using the multi-measure tool in ROI manager, the table format it produces does not work with the plug in written for our group I was wondering if anyone could help with this. I need to transpose the table from default Image J columns to rows.

Any help our advise would be much appreciated.

Cheers,

Jacob
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Transpose Table in Image J help

Cammer, Michael
One way to do this would be to write a macro where each column of the results you want would be an array, use ColumnName[index] = getResults("ColumnName", index) and then you use the print command with tabs to reorder the data in rows.  There may already be a macro or plugin for this-- let's see if anyone else responds.

But it might be simpler just to just do this in Excel or some other spreadsheet.  Here are the first three google URLs returned in a search for this:
https://support.office.com/en-in/article/Switch-transpose-columns-and-rows-ed1215f5-59af-47e6-953b-0b513b094dc2
https://support.office.com/en-IN/article/Transpose-rotate-data-from-rows-to-columns-or-vice-versa-3419f2e3-beab-4318-aae5-d0f862209744
http://www.howtogeek.com/howto/15810/convert-a-row-to-a-column-or-backwards-in-google-docs-spreadsheets/


_________________________________________
Michael Cammer, Optical Microscopy Specialist
http://ocs.med.nyu.edu/microscopy
http://microscopynotes.com/
Cell: (914) 309-3270

________________________________________
From: ImageJ Interest Group [[hidden email]] on behalf of Jacob Lewis [[hidden email]]
Sent: Friday, October 02, 2015 7:10 PM
To: [hidden email]
Subject: Transpose Table in Image J help

Hi All,

I am using the multi-measure tool in ROI manager, the table format it produces does not work with the plug in written for our group I was wondering if anyone could help with this. I need to transpose the table from default Image J columns to rows.

Any help our advise would be much appreciated.

Cheers,

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

------------------------------------------------------------
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email.
=================================

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Transpose Table in Image J help

Jacob Lewis
Hi Michael,

Thanks for your response. I have no programming experience even with macro language. I do need to learn though (that is pretty apparent). I was thinking of using excel but I didn’t think it could handle large data sets.
I have done some googling and I couldn’t find any plugins or macros that would do this.

I will look into seeing if I can figure out the macro you suggested.

Cheers,

Jacob

> On 3 Oct 2015, at 10:02 am, Cammer, Michael <[hidden email]> wrote:
>
> One way to do this would be to write a macro where each column of the results you want would be an array, use ColumnName[index] = getResults("ColumnName", index) and then you use the print command with tabs to reorder the data in rows.  There may already be a macro or plugin for this-- let's see if anyone else responds.
>
> But it might be simpler just to just do this in Excel or some other spreadsheet.  Here are the first three google URLs returned in a search for this:
> https://support.office.com/en-in/article/Switch-transpose-columns-and-rows-ed1215f5-59af-47e6-953b-0b513b094dc2
> https://support.office.com/en-IN/article/Transpose-rotate-data-from-rows-to-columns-or-vice-versa-3419f2e3-beab-4318-aae5-d0f862209744
> http://www.howtogeek.com/howto/15810/convert-a-row-to-a-column-or-backwards-in-google-docs-spreadsheets/
>
>
> _________________________________________
> Michael Cammer, Optical Microscopy Specialist
> http://ocs.med.nyu.edu/microscopy
> http://microscopynotes.com/
> Cell: (914) 309-3270
>
> ________________________________________
> From: ImageJ Interest Group [[hidden email]] on behalf of Jacob Lewis [[hidden email]]
> Sent: Friday, October 02, 2015 7:10 PM
> To: [hidden email]
> Subject: Transpose Table in Image J help
>
> Hi All,
>
> I am using the multi-measure tool in ROI manager, the table format it produces does not work with the plug in written for our group I was wondering if anyone could help with this. I need to transpose the table from default Image J columns to rows.
>
> Any help our advise would be much appreciated.
>
> Cheers,
>
> Jacob
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> ------------------------------------------------------------
> This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email.
> =================================
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Transpose Table in Image J help

Rasband, Wayne (NIH/NIMH) [E]
In reply to this post by Jacob Lewis
> On Oct 2, 2015, at 7:10 PM, Jacob Lewis <[hidden email]> wrote:
>
> Hi All,
>
> I am using the multi-measure tool in ROI manager, the table format it produces does not work with the plug in written for our group I was wondering if anyone could help with this. I need to transpose the table from default Image J columns to rows.
>
> Any help our advise would be much appreciated.

Hi Jacob,

The following JavaScript code transposes the the Results table. You will need to upgrade to the latest daily build (1.50d6) to transpose tables that have a "Label" column.

-wayne

  rt1 = Analyzer.getResultsTable();
  rt2 = new ResultsTable();
  hdr = rt1.getHeadings();
  for (i=0; i<rt1.getCounter(); i++) {
     for (j=0; j<hdr.length; j++) {
        if (i==0) rt2.setValue("Column", j, hdr[j])
        value = rt1.getStringValue(hdr[j], i);
        rt2.setValue(""+(i+1), j, value)
     }
  }
  rt2.showRowNumbers(false);
  rt2.show("Results");
     

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Transpose Table in Image J help

Jacob Lewis
Hi Wayne,

Thank you so much you have saved me at least a few days to trying to figure this out much appreciated!

Cheers,

Jacob

> On 3 Oct 2015, at 2:02 pm, Rasband, Wayne (NIH/NIMH) [E] <[hidden email]> wrote:
>
>> On Oct 2, 2015, at 7:10 PM, Jacob Lewis <[hidden email]> wrote:
>>
>> Hi All,
>>
>> I am using the multi-measure tool in ROI manager, the table format it produces does not work with the plug in written for our group I was wondering if anyone could help with this. I need to transpose the table from default Image J columns to rows.
>>
>> Any help our advise would be much appreciated.
>
> Hi Jacob,
>
> The following JavaScript code transposes the the Results table. You will need to upgrade to the latest daily build (1.50d6) to transpose tables that have a "Label" column.
>
> -wayne
>
>  rt1 = Analyzer.getResultsTable();
>  rt2 = new ResultsTable();
>  hdr = rt1.getHeadings();
>  for (i=0; i<rt1.getCounter(); i++) {
>     for (j=0; j<hdr.length; j++) {
>        if (i==0) rt2.setValue("Column", j, hdr[j])
>        value = rt1.getStringValue(hdr[j], i);
>        rt2.setValue(""+(i+1), j, value)
>     }
>  }
>  rt2.showRowNumbers(false);
>  rt2.show("Results");
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Transpose Table in Image J help

Jacob Lewis
In reply to this post by Rasband, Wayne (NIH/NIMH) [E]
Hi Wayne,

Sorry to bother you again. Would I apply the same logic as in the javascript you provided to take all the columns output by multi-measure (i.e. mean grey value) and merge them into one column? Or is that even more difficult/multi-step process? I know I would have to provide an additional column like molecule or trajectory to separate out each measurement. It appears I wasn’t very clear when I mentioned “transpose” in my last email, although that code was helpful. The plugin reads columns rather and rows, see screen shot for typical format. This is the format I need to get the data in after the multi-measure on all slices.

I apologise if my explanation is a bit confusing I’m a biochemist trying to analyse and navigate image analysis for some single molecule data.

Cheers,

Jacob

 

> On 3 Oct 2015, at 2:02 pm, Rasband, Wayne (NIH/NIMH) [E] <[hidden email]> wrote:
>
>> On Oct 2, 2015, at 7:10 PM, Jacob Lewis <[hidden email]> wrote:
>>
>> Hi All,
>>
>> I am using the multi-measure tool in ROI manager, the table format it produces does not work with the plug in written for our group I was wondering if anyone could help with this. I need to transpose the table from default Image J columns to rows.
>>
>> Any help our advise would be much appreciated.
>
> Hi Jacob,
>
> The following JavaScript code transposes the the Results table. You will need to upgrade to the latest daily build (1.50d6) to transpose tables that have a "Label" column.
>
> -wayne
>
>  rt1 = Analyzer.getResultsTable();
>  rt2 = new ResultsTable();
>  hdr = rt1.getHeadings();
>  for (i=0; i<rt1.getCounter(); i++) {
>     for (j=0; j<hdr.length; j++) {
>        if (i==0) rt2.setValue("Column", j, hdr[j])
>        value = rt1.getStringValue(hdr[j], i);
>        rt2.setValue(""+(i+1), j, value)
>     }
>  }
>  rt2.showRowNumbers(false);
>  rt2.show("Results");
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html


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

Screen Shot 2015-10-03 at 9.13.24 pm.png (183K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Transpose Table in Image J help

Brandon Hurr
Could you describe the problem in a bit more detail with some sort of
example table?

You said you want to transpose, but then you want all of the gray value
data in a single column. The Results table displays each data type in
columns with ROIs as rows. Wayne's transpose function takes that and makes
ROIs as columns and data types (roundness, area,...) as rows.

If neither one of those works for you, then you need to describe what you
have and what you need better.

B

On Sat, Oct 3, 2015 at 4:20 AM, Jacob Lewis <[hidden email]> wrote:

> Hi Wayne,
>
> Sorry to bother you again. Would I apply the same logic as in the
> javascript you provided to take all the columns output by multi-measure
> (i.e. mean grey value) and merge them into one column? Or is that even more
> difficult/multi-step process? I know I would have to provide an additional
> column like molecule or trajectory to separate out each measurement. It
> appears I wasn’t very clear when I mentioned “transpose” in my last email,
> although that code was helpful. The plugin reads columns rather and rows,
> see screen shot for typical format. This is the format I need to get the
> data in after the multi-measure on all slices.
>
> I apologise if my explanation is a bit confusing I’m a biochemist trying
> to analyse and navigate image analysis for some single molecule data.
>
> Cheers,
>
> Jacob
>
>
> > On 3 Oct 2015, at 2:02 pm, Rasband, Wayne (NIH/NIMH) [E] <
> [hidden email]> wrote:
> >
> >> On Oct 2, 2015, at 7:10 PM, Jacob Lewis <[hidden email]> wrote:
> >>
> >> Hi All,
> >>
> >> I am using the multi-measure tool in ROI manager, the table format it
> produces does not work with the plug in written for our group I was
> wondering if anyone could help with this. I need to transpose the table
> from default Image J columns to rows.
> >>
> >> Any help our advise would be much appreciated.
> >
> > Hi Jacob,
> >
> > The following JavaScript code transposes the the Results table. You will
> need to upgrade to the latest daily build (1.50d6) to transpose tables that
> have a "Label" column.
> >
> > -wayne
> >
> >  rt1 = Analyzer.getResultsTable();
> >  rt2 = new ResultsTable();
> >  hdr = rt1.getHeadings();
> >  for (i=0; i<rt1.getCounter(); i++) {
> >     for (j=0; j<hdr.length; j++) {
> >        if (i==0) rt2.setValue("Column", j, hdr[j])
> >        value = rt1.getStringValue(hdr[j], i);
> >        rt2.setValue(""+(i+1), j, value)
> >     }
> >  }
> >  rt2.showRowNumbers(false);
> >  rt2.show("Results");
> >
> >
> > --
> > 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
Reply | Threaded
Open this post in threaded view
|

Re: Transpose Table in Image J help

Jacob Lewis
Hi Brandon,

See dropbox link an example table output for the ImageJ multi-measure table “multi-measure" and the other is the table format required by the plugin I need to use, called “Newtableformat”.

Basically what I need to achieve is to take all the columns labelled Mean1… Mean2… etc and merge them into a single column one after another, create a new column that contains the corresponds column number to enable a way to separate out each measurement.

I hope this explains better my problem.


https://www.dropbox.com/sh/s7njkwbzgkv0ksk/AAB0sAPHXTVeRWmazsZiRXroa?dl=0 <https://www.dropbox.com/sh/s7njkwbzgkv0ksk/AAB0sAPHXTVeRWmazsZiRXroa?dl=0>

Many thanks for your patience!

Cheers,

Jacob


> On 5 Oct 2015, at 8:56 am, Brandon Hurr <[hidden email]> wrote:
>
> Could you describe the problem in a bit more detail with some sort of
> example table?
>
> You said you want to transpose, but then you want all of the gray value
> data in a single column. The Results table displays each data type in
> columns with ROIs as rows. Wayne's transpose function takes that and makes
> ROIs as columns and data types (roundness, area,...) as rows.
>
> If neither one of those works for you, then you need to describe what you
> have and what you need better.
>
> B
>
> On Sat, Oct 3, 2015 at 4:20 AM, Jacob Lewis <[hidden email]> wrote:
>
>> Hi Wayne,
>>
>> Sorry to bother you again. Would I apply the same logic as in the
>> javascript you provided to take all the columns output by multi-measure
>> (i.e. mean grey value) and merge them into one column? Or is that even more
>> difficult/multi-step process? I know I would have to provide an additional
>> column like molecule or trajectory to separate out each measurement. It
>> appears I wasn’t very clear when I mentioned “transpose” in my last email,
>> although that code was helpful. The plugin reads columns rather and rows,
>> see screen shot for typical format. This is the format I need to get the
>> data in after the multi-measure on all slices.
>>
>> I apologise if my explanation is a bit confusing I’m a biochemist trying
>> to analyse and navigate image analysis for some single molecule data.
>>
>> Cheers,
>>
>> Jacob
>>
>>
>>> On 3 Oct 2015, at 2:02 pm, Rasband, Wayne (NIH/NIMH) [E] <
>> [hidden email]> wrote:
>>>
>>>> On Oct 2, 2015, at 7:10 PM, Jacob Lewis <[hidden email]> wrote:
>>>>
>>>> Hi All,
>>>>
>>>> I am using the multi-measure tool in ROI manager, the table format it
>> produces does not work with the plug in written for our group I was
>> wondering if anyone could help with this. I need to transpose the table
>> from default Image J columns to rows.
>>>>
>>>> Any help our advise would be much appreciated.
>>>
>>> Hi Jacob,
>>>
>>> The following JavaScript code transposes the the Results table. You will
>> need to upgrade to the latest daily build (1.50d6) to transpose tables that
>> have a "Label" column.
>>>
>>> -wayne
>>>
>>> rt1 = Analyzer.getResultsTable();
>>> rt2 = new ResultsTable();
>>> hdr = rt1.getHeadings();
>>> for (i=0; i<rt1.getCounter(); i++) {
>>>    for (j=0; j<hdr.length; j++) {
>>>       if (i==0) rt2.setValue("Column", j, hdr[j])
>>>       value = rt1.getStringValue(hdr[j], i);
>>>       rt2.setValue(""+(i+1), j, value)
>>>    }
>>> }
>>> rt2.showRowNumbers(false);
>>> rt2.show("Results");
>>>
>>>
>>> --
>>> 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
Reply | Threaded
Open this post in threaded view
|

Re: Transpose Table in Image J help

Rasband, Wayne (NIH/NIMH) [E]
In reply to this post by Jacob Lewis
> On Oct 3, 2015, at 7:44 AM, Jacob Lewis <[hidden email]> wrote:
>
> Hi Wayne,
>
> Sorry to bother you again. Would I apply the same logic as in the javascript you provided to take all the columns output by multi-measure (i.e. mean grey value) and merge them into one column? Or is that even more difficult/multi-step process? I know I would have to provide an additional column like molecule or trajectory to separate out each measurement. It appears I wasn’t very clear when I mentioned “transpose” in my last email, although that code was helpful. The plugin reads columns rather and rows, see screen shot for typical format. This is the format I need to get the data in after the multi-measure on all slices.

The following JavaScript, which replaces the "Multi Measure" command, measures each ROI in the ROI Manager on each of the images in the stack. All measurements for each parameter are in a single column. Enable “Stack position” in the Analyze>Set Measurements dialog to display the slice numbers in the Results table.

  img = IJ.getImage();
  IJ.run("Clear Results");
  rm = RoiManager.getInstance();
  rois = rm.getRoisAsArray();
  slices = img.getStackSize();
  for (slice=1; slice<=slices; slice++) {
     img.setSlice(slice);
     for (i=0; i<rois.length; i++) {
         img.setRoi(rois[i]);
         IJ.run(img, "Measure", "");
     }
  }

Here is a macro version:

  run("Clear Results");
  roiManager("Deselect");
  roiManager("Remove Slice Info");
  n = roiManager("count");
  for (slice=1; slice<=nSlices; slice++) {
     setSlice(slice);
     for (i=0; i<n; i++) {
        roiManager("select", i);
        run("Measure");
     }
  }

-wayne




--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Transpose Table in Image J help

Emanuele Martini
In reply to this post by Jacob Lewis
Hi to all,
I really think that one of the biggest enhancement in future of ImageJ/Fiji was a more easy and more optionable Result table.
I think at least the possibilty to open more than one together will be very good.
Since, if you have macro/programming/scripting experience you could figure out, but if not - and this is the case of many biologist and scientists - it could be a very hard problem transpose a matrix or create a single column with all the values; or display the result of an analysis in a result table and another analysis in another one.

I think that will enhance greatly Fiji/ImageJ.
It is only a suggestion of course,
have a nice day
Emanuele Martini
Image Analyst @Ifom-IEO research campus -MI-
Reply | Threaded
Open this post in threaded view
|

Re: Transpose Table in Image J help

ctrueden
Hi Emanuele,

> I really think that one of the biggest enhancement in future of
> ImageJ/Fiji was a more easy and more optionable Result table.

Actually, ImageJ2 has a rewritten-from-scratch ResultsTable implementation:

*
https://github.com/imagej/imagej-common/tree/imagej-common-0.18.0/src/main/java/net/imagej/table

Review, comments and suggestions are welcome.

Regards,
Curtis

On Mon, Oct 5, 2015 at 3:15 AM, Emanuele Martini <[hidden email]>
wrote:

> Hi to all,
> I really think that one of the biggest enhancement in future of ImageJ/Fiji
> was a more easy and more optionable Result table.
> I think at least the possibilty to open more than one together will be very
> good.
> Since, if you have macro/programming/scripting experience you could figure
> out, but if not - and this is the case of many biologist and scientists -
> it
> could be a very hard problem transpose a matrix or create a single column
> with all the values; or display the result of an analysis in a result table
> and another analysis in another one.
>
> I think that will enhance greatly Fiji/ImageJ.
> It is only a suggestion of course,
> have a nice day
> Emanuele Martini
>
>
>
> -----
> Image Analyst @Ifom-IEO research campus -MI-
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Transpose-Table-in-Image-J-help-tp5014534p5014549.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Transpose Table in Image J help

Rasband, Wayne (NIH/NIMH) [E]
In reply to this post by Emanuele Martini
> On Oct 5, 2015, at 4:15 AM, Emanuele Martini <[hidden email]> wrote:
>
> Hi to all,
> I really think that one of the biggest enhancement in future of ImageJ/Fiji
> was a more easy and more optionable Result table.
> I think at least the possibilty to open more than one together will be very
> good.

ImageJ can have any number of results tables open at a time but only one, named “Results”, can be active. To rename a table, right click on it and select “Rename” from the drop down menu, or select “Rename” from the table’s File menu. Renaming a table as “Results” makes it the active table. In plugins, macros and scripts, use IJ.renameResults(“new-name”).

-wayne
 

> Since, if you have macro/programming/scripting experience you could figure
> out, but if not - and this is the case of many biologist and scientists - it
> could be a very hard problem transpose a matrix or create a single column
> with all the values; or display the result of an analysis in a result table
> and another analysis in another one.
>
> I think that will enhance greatly Fiji/ImageJ.
> It is only a suggestion of course,
> have a nice day
> Emanuele Martini
>
> -----
> Image Analyst @Ifom-IEO research campus -MI-
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Transpose-Table-in-Image-J-help-tp5014534p5014549.html
> Sent from the ImageJ mailing list archive at Nabble.com.

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