Posted by
Andy Schofield on
URL: http://imagej.273.s1.nabble.com/Macro-to-save-plot-profile-data-as-text-tp5018666p5018682.html
Thanks Volko.
That moves me forward a little. The file saves now but only as a tab delimited file despite the filename being a .csv. Is there a mechanism to save this as a CSV as it seems to be with the GUI SaveAs?
Do I need to use a different Type= in the original new table creation, for instance? What are the different possible types?
Cheers
Andy
-----Original Message-----
From: ImageJ Interest Group [mailto:
[hidden email]] On Behalf Of Straub, Volko A. (Dr.)
Sent: 09 May 2017 11:14
To:
[hidden email]
Subject: Re: [Ext] Re: Macro to save plot profile data as text
Hi Andy,
I think your problem is that you use your window title as the first argument in the SaveAs command. The first argument should be format argument (see macro function documentation). Try replacing saveAs(titleRG, ImageDir+"\\"+titleRG+".csv"); with saveAs("text", ImageDir+"\\"+titleRG+".csv");
Hope this helps,
Volko
-----Original Message-----
From: Andy Schofield [mailto:
[hidden email]]
Sent: 09 May 2017 10:31
To:
[hidden email]
Subject: Re: [Ext] Re: Macro to save plot profile data as text
Hi All,
I'm having a similar problem where the SaveAs is failing in a macro when I try to save my bespoke table window as a CSV file.
I create my table as such
titleRG="RedtoGreen";
tblRG = "["+titleRG+"]";
fRG = tblRG;
run("New... ", "name="+tblRG+" type=Table");
and then populate it using
print(fRG,(CurrCol+CHIPWIDTH/2) + "\t" + (CurrRow+CHIPHEIGHT/2) + "\t" + lastline[4] + "\t" + lastline[6]);
and finally save the table as
selectWindow("RedtoGreen");
saveAs(titleRG, ImageDir+"\\"+titleRG+".csv");
When I run the macro, the RedtoGreen table is created OK with tab separated fields but the saveAs reports:-
Unsupported save() or saveAs() file format: "redtogreen"
I can choose the RedtoGreen table manually and choose File->Save As. The default filename name displayed is RedtoGreen.txt but I can change that to redtoGreen.csv and the tbale saves as expected (i.e. a comma separated file) so it would seem the behaviour is different between the GUI and the macro handler (or that I'm missing something obvious ;-) )
Cheers
Andy
-----Original Message-----
From: ImageJ Interest Group [mailto:
[hidden email]] On Behalf Of arobisson
Sent: 08 May 2017 02:36
To:
[hidden email]
Subject: Re: [Ext] Re: Macro to save plot profile data as text
Hi Volko,
It works. Thank you!
Yes, I used the example from this discussion.. but I got stuck… I guess I have still a bit to learn to write my own macro… Thank you, Agathe
From: Volko Straub [via ImageJ] [mailto:
[hidden email]]
Sent: 07 May, 2017 2:30 AM
To: Agathe Robisson <
[hidden email]>
Subject: [Ext] Re: Macro to save plot profile data as text
Dear Agathe,
The problem is that your focus is not on the log window when you try to save its content. Also, I don't think the 'Results' option will work with the log window. Change
saveAs("Results", path);
to
selectWindow("Log");
saveAs("Text", path);
A quick websearch shows some similar questions (e.g.
http://stackoverflow.com/questions/29879988/solvedimagej-macro-how-to-save-plot-profile-data-in-a-text-file<
https://urldefense.proofpoint.com/v2/url?u=http-3A__stackoverflow.com_questions_29879988_solvedimagej-2Dmacro-2Dhow-2Dto-2Dsave-2Dplot-2Dprofile-2Ddata-2Din-2Da-2Dtext-2Dfile&d=CwMFaQ&c=uGuXJ43KPkPWEl2imVFDmZQlhQUET7pVRA2PDIOxgqw&r=ZSB5F8Ew5Pfa9PJrJrErd_qpXmtjZqfSdSGDjHk5aOs&m=EqPFXdRMzDelyEe4t7UBrRoYEh-gjrJIEA8keliIpPk&s=Hhcyi80Y9Tsz892UNZVr3AF1vXfI4bjG9HnOyUyJGIk&e=>)
that use a results window rather than the log window to list the plot values. Hope this helps, Volko
On 07/05/2017 03:36, arobisson wrote:
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html<
https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.nih.gov_ij_list.html&d=CwMFaQ&c=uGuXJ43KPkPWEl2imVFDmZQlhQUET7pVRA2PDIOxgqw&r=ZSB5F8Ew5Pfa9PJrJrErd_qpXmtjZqfSdSGDjHk5aOs&m=EqPFXdRMzDelyEe4t7UBrRoYEh-gjrJIEA8keliIpPk&s=fP2Tm56p6s03gsXrrBxNDG-BMw7ibVeutfCU7CG6ynk&e=>
________________________________
If you reply to this email, your message will be added to the discussion below:
http://imagej.1557.x6.nabble.com/Macro-to-save-plot-profile-data-as-text-tp5018666p5018667.html<
https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.1557.x6.nabble.com_Macro-2Dto-2Dsave-2Dplot-2Dprofile-2Ddata-2Das-2Dtext-2Dtp5018666p5018667.html&d=CwMFaQ&c=uGuXJ43KPkPWEl2imVFDmZQlhQUET7pVRA2PDIOxgqw&r=ZSB5F8Ew5Pfa9PJrJrErd_qpXmtjZqfSdSGDjHk5aOs&m=EqPFXdRMzDelyEe4t7UBrRoYEh-gjrJIEA8keliIpPk&s=ZywJpIyzMABvNMhwfMz1lT3ARoEkglpUP0EC5BcFyhc&e=>
To unsubscribe from Macro to save plot profile data as text, click here<
https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.1557.x6.nabble.com_template_NamlServlet.jtp-3Fmacro-3Dunsubscribe-5Fby-5Fcode-26node-3D5018666-26code-3DYXJvYmlzc29uQHNsYi5jb218NTAxODY2NnwtNTYyMjUwMTQ4&d=CwMFaQ&c=uGuXJ43KPkPWEl2imVFDmZQlhQUET7pVRA2PDIOxgqw&r=ZSB5F8Ew5Pfa9PJrJrErd_qpXmtjZqfSdSGDjHk5aOs&m=EqPFXdRMzDelyEe4t7UBrRoYEh-gjrJIEA8keliIpPk&s=qRWSjpqlbDJ86fBlG7VwyOabXpduGCsLoVCKy3Ygi0U&e=>.
NAML<
https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.1557.x6.nabble.com_template_NamlServlet.jtp-3Fmacro-3Dmacro-5Fviewer-26id-3Dinstant-5Fhtml-2521nabble-253Aemail.naml-26base-3Dnabble.naml.namespaces.BasicNamespace-2Dnabble.view.web.template.NabbleNamespace-2Dnabble.view.web.template.NodeNamespace-26breadcrumbs-3Dnotify-5Fsubscribers-2521nabble-253Aemail.naml-2Dinstant-5Femails-2521nabble-253Aemail.naml-2Dsend-5Finstant-5Femail-2521nabble-253Aemail.naml&d=CwMFaQ&c=uGuXJ43KPkPWEl2imVFDmZQlhQUET7pVRA2PDIOxgqw&r=ZSB5F8Ew5Pfa9PJrJrErd_qpXmtjZqfSdSGDjHk5aOs&m=EqPFXdRMzDelyEe4t7UBrRoYEh-gjrJIEA8keliIpPk&s=1WUy-xtxmIEGNq4RGPG1asiFrMPkBBV2-27MDaqOPSI&e=>
--
View this message in context:
http://imagej.1557.x6.nabble.com/Macro-to-save-plot-profile-data-as-text-tp5018666p5018669.htmlSent from the ImageJ mailing list archive at Nabble.com.
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.htmlThe information contained in this message is intended for the addressee only and may contain sensitive information. If you are not the addressee, please delete this message and notify the sender; you should not copy or distribute this message or disclose its contents to anyone. Any views or opinions expressed in this message are those of the individual(s) and not necessarily of the organisation. No reliance may be placed on this message without written confirmation from an authorised representative of its contents. No guarantee is implied that this message or any attachment is virus free or has not been intercepted and amended.
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.htmlThe information contained in this message is intended for the addressee only and may contain sensitive information. If you are not the addressee, please delete this message and notify the sender; you should not copy or distribute this message or disclose its contents to anyone. Any views or opinions expressed in this message are those of the individual(s) and not necessarily of the organisation. No reliance may be placed on this message without written confirmation from an authorised representative of its contents. No guarantee is implied that this message or any attachment is virus free or has not been intercepted and amended.
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html