Hi All,
I have a question regarding writing macro to save result files from "analyze particle". As an exmaple, I can open an image and run analyze particle and save measurements into an excel file in a pre-defined folder with a pre-defined name : saveAs("Measurements", "C:\\Documents and Settings\\Desktop\\Results.xls"); ". But what I would like to do is to use getDirectory("image") and getTitle("image") so to save the excel file: (1) in the folder that contains the image and (2) with a title that reflects the image being analyzed, say "Results - xx.xls" (xx is the image name). For some reason, I can create new images and save those as I wanted. But not for the results.xls files. Any help is greatly appreciated - thanks in advance! Yuhong --------------------------------------------------------------------------- This e-mail is confidential. If you are not the addressee or an authorized recipient of this message, any distribution, copying, publication or use of this information for any purpose is prohibited. Please notify the sender immediately by e-mail and then delete this message. Ce message est confidentiel. Si vous n'etes pas le destinataire designe de ce message ou une personne autorisee a l'utiliser, toute distribution, copie, publication ou usage a quelques fins que ce soit des informations contenues dans ce message sont interdits. Merci d'informer immediatement l'expediteur par messagerie electronique et d'ensuite detruire ce message. --------------------------------------------------------------------------- |
On Jan 15, 2009, at 10:57 AM, Wu, Yuhong wrote:
> Hi All, > > I have a question regarding writing macro to save result files from > "analyze particle". > > As an exmaple, I can open an image and run analyze particle and save > measurements into an excel file in a pre-defined folder with a > pre-defined name : saveAs("Measurements", "C:\\Documents and > Settings\\Desktop\\Results.xls"); ". > > But what I would like to do is to use getDirectory("image") and > getTitle("image") so to save the excel file: > (1) in the folder that contains the image and > (2) with a title that reflects the image being analyzed, say "Results - > xx.xls" (xx is the image name). > > For some reason, I can create new images and save those as I wanted. > But > not for the results.xls files. > > Any help is greatly appreciated - thanks in advance! > > Yuhong Here is macro that does this. It removes the extension from the image title and replaces it with ".xls" because saveAs("Measurements", path) doesn't do it, although it probably should. open(""); run("Measure"); dir = getDirectory("image"); name = getTitle; index = lastIndexOf(name, "."); if (index!=-1) name = substring(name, 0, index); name = name + ".xls"; saveAs("Measurements", dir+name); print(dir+name); -wayne |
Dear all:
I try to do the following: once a image is opened (a dicom format) , I would like to rename its original name to be replaced by a specific caracter sequence (string) of a line of the Show Info . Pls, is ther some way to do this with ImageJ in a automatic fashion? Thank yu evry much for your kindness JFC --- El jue, 15/1/09, Wayne Rasband <[hidden email]> escribió: De: Wayne Rasband <[hidden email]> Asunto: Re: Macro help - result file save Para: [hidden email] Fecha: jueves, 15 enero, 2009 5:52 On Jan 15, 2009, at 10:57 AM, Wu, Yuhong wrote: > Hi All, > > I have a question regarding writing macro to save result files from > "analyze particle". > > As an exmaple, I can open an image and run analyze particle and save > measurements into an excel file in a pre-defined folder with a > pre-defined name : saveAs("Measurements", "C:\\Documents and > Settings\\Desktop\\Results.xls"); ". > > But what I would like to do is to use getDirectory("image") and > getTitle("image") so to save the excel file: > (1) in the folder that contains the image and > (2) with a title that reflects the image being analyzed, say "Results - > xx.xls" (xx is the image name). > > For some reason, I can create new images and save those as I wanted. But > not for the results.xls files. > > Any help is greatly appreciated - thanks in advance! > > Yuhong Here is macro that does this. It removes the extension from the image title and replaces it with ".xls" because saveAs("Measurements", path) doesn't do it, although it probably should. open(""); run("Measure"); dir = getDirectory("image"); name = getTitle; index = lastIndexOf(name, "."); if (index!=-1) name = substring(name, 0, index); name = name + ".xls"; saveAs("Measurements", dir+name); print(dir+name); -wayne |
Hi,
The getInfo() macro function will return the information. Then use the rename() function to rename the image. Here's how to rename the image with its height info. run("Blobs (25K)"); run("Show Info..."); info = getInfo() x = split(info, "\n"); rename(x[3]); Cheers, Ben On Jan 16, 2009, at 2:12 PM, Juan Francisco wrote: > Dear all: > I try to do the following: > once a image is opened (a dicom format) , I would like to rename > its original name to be replaced by a specific caracter sequence > (string) of a line of the Show Info . > Pls, is ther some way to do this with ImageJ in a automatic fashion? > Thank yu evry much for your kindness > JFC > > --- El jue, 15/1/09, Wayne Rasband <[hidden email]> escribió: > > De: Wayne Rasband <[hidden email]> > Asunto: Re: Macro help - result file save > Para: [hidden email] > Fecha: jueves, 15 enero, 2009 5:52 > > On Jan 15, 2009, at 10:57 AM, Wu, Yuhong wrote: > >> Hi All, >> >> I have a question regarding writing macro to save result files from >> "analyze particle". >> >> As an exmaple, I can open an image and run analyze particle and save >> measurements into an excel file in a pre-defined folder with a >> pre-defined name : saveAs("Measurements", > "C:\\Documents and >> Settings\\Desktop\\Results.xls"); ". >> >> But what I would like to do is to use getDirectory("image") and >> getTitle("image") so to save the excel file: >> (1) in the folder that contains the image and >> (2) with a title that reflects the image being analyzed, say "Results > - >> xx.xls" (xx is the image name). >> >> For some reason, I can create new images and save those as I >> wanted. But >> not for the results.xls files. >> >> Any help is greatly appreciated - thanks in advance! >> >> Yuhong > > Here is macro that does this. It removes the extension from the > image title and > replaces it with ".xls" because saveAs("Measurements", path) > doesn't do it, although it probably should. > > open(""); > run("Measure"); > dir = getDirectory("image"); > name = getTitle; > index = lastIndexOf(name, "."); > if (index!=-1) name = substring(name, 0, index); > name = name + ".xls"; > saveAs("Measurements", dir+name); > print(dir+name); > > -wayne > > > > |
This post was updated on .
In reply to this post by Wayne Rasband
Hi all,
I know this is an old thread, but I've got a question about it. I'm using the macro Wayne provided and it's working very good. However, I've got a problem opening the created excel file. If I open the excel file, next error appears: Does anybody know how to use the macro without getting the error. I need to merge several of these excel files after the analysis, using an excel VBA. I think the error is interrupting this next step. Thanks in advance! Lodi |
Hi Lodi,
looks like a funny "feature" introduced by Microsoft - maybe you can avoid it by saving as '.csv' instead of '.xls'. Use Edit>Options>Input/Output to set the default extension for tables, and also change the extension in your macro from '.xls' to '.csv' if it appears there. Michael ________________________________________________________________ On Nov 22, 2013, at 12:22, Lodi wrote: > Hi all, > > I know this is an old thread, but I've got a question about it. I'm using > the macro Wayne provided and it's working very good. However, I've got a > problem opening the created excel file. If I open the excel file, next error > appears: > > <http://imagej.1557.x6.nabble.com/file/n5005655/error.png> > > Does anybody know how to use the macro without getting the error. I need to > merge several of these excel files after the analysis, using a excel VBA. I > think the error is interrupting this next step. > > Thanks in advance! > > Lodi -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Michal, Thanks a lot for your help. Indeed saving the files as .csv solves the problem. Thanks! Lodi
2013/11/22 Michael Schmid-3 [via ImageJ] <[hidden email]> Hi Lodi, |
In reply to this post by Wayne Rasband
Actually I have another question about this macro. Does anybody know if it is possible to name the sheets from the excel files only after the last 30 characters from the TIF file name.
It would be the best if the excel files are still named after the whole TIF file name, but if it's not possible to change the sheet name without changing the excel file name, its alright to change the excel file name as well. My problem is that the TIF files have names which are way longer than 31 characters (max sheet name in excel). I need to do some further analysis with the excel files afterward; these analysis are interrupted because of the wrong sheet name. Again I would greatly appreciate any help with this! Lodi. |
Hi Lodi,
To change the filenames is simple macro programming; it would be worthwhile learning it... To start, see the macro documentation at http://rsb.info.nih.gov/ij/developer/macro/macros.html http://rsb.info.nih.gov/ij/developer/macro/functions.html http://fiji.sc/Introduction_into_Macro_Programming In the current case, instead of name = getTitle(); index = lastIndexOf(name, "."); if (index!=-1) name = substring(name, 0, index); name = name + ".csv"; saveAs("Measurements", dir+name); you can use something like the following (I have not tried, there may be errors in it) name = getTitle(); index = lastIndexOf(name, "."); if (index!=-1) name = substring(name, 0, index); maxLength = 30; length = lengthOf(name); if (length > maxLength) name = substring(name, length-maxLength); name = name + ".csv"; saveAs("Measurements", dir+name); For renaming the Excel sheets without having a different filename, you have to search the Excel or VBA documentation... Michael ________________________________________________________________ On Nov 22, 2013, at 16:09, Lodi wrote: > Actually I have another question about this macro. Does anybody know if it is > possible to name the sheets from the excel files only after the last 30 > characters from the TIF file name. > > It would be the best if the excel files are still named after the whole TIF > file name, but if it's not possible to change the sheet name without > changing the excel file name, its alright to change the excel file name as > well. > > My problem is that the TIF files have names which are way longer than 31 > characters (max sheet name in excel). I need to do some further analysis > with the excel files afterward; these analysis are interrupted because of > the wrong sheet name. > > Again I would greatly appreciate any help with this! > > Lodi. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Michael, Thanks again. I agree with you it might be worthwhile to learn some more about macro use. I just know 2 days the function of macros so it is a bid new for me:P. Thanks for the links.
Lodi 2013/11/22 Michael Schmid-3 [via ImageJ] <[hidden email]> Hi Lodi, |
Free forum by Nabble | Edit this page |