Importing results?

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

Importing results?

Dr Adam Cliffe
Hi,

I'm trying to write a macro which will import a tab delimited text file or
excel sheet and extract some of the values from it.
I've tried using the run("Results... ", "open=my file path"); command and I
get an untitled results window. Using the 'open' command with an excel
sheet gets me a results window with the correct file name but in both cases
I can't extract any information from the table.
I've tried using IJ.renameResults to rename the table as 'Results' but I
just get the message that it isn't a results window.

does anyone have a suggestion of how to get around this? (or another way to
open a tab delimited file into a macro accessible format?)

thanks

Adam
Reply | Threaded
Open this post in threaded view
|

Re: Importing results?

George Patterson-3
Hi Adam,
I've pasted a part of a macro I've been using below that might help.
It's not too elegant and I'm sure someone has a better way to do it, but it might work until they post a better approach.
It's slow with large files and I've run into memory problems with files >0.5GB.  
At the end you should have a 32-bit image open with each pixel having the values in your text.  You should be able to access them with selectImage(myInfoFile) and getPixel(x,y).
Best,
George

print("\\Clear");
pathfile=File.openDialog("Choose the file to Open:");
filestring=File.openAsString(pathfile);
dir1=File.directory;
InfoFile=File.nameWithoutExtension;
print(filestring);
print("\\Update0:");//replaces in the entries first row (column headers in my case), you might want to get rid of this line
selectWindow("Log");
saveAs("text", dir1+InfoFile+"_saved"+".txt");
run("Text Image... ", "open="+dir1+InfoFile+"_saved"+".txt");
myInfoFile=getImageID();




On Feb 27, 2012, at 12:50 AM, Adam Cliffe wrote:

> Hi,
>
> I'm trying to write a macro which will import a tab delimited text file or
> excel sheet and extract some of the values from it.
> I've tried using the run("Results... ", "open=my file path"); command and I
> get an untitled results window. Using the 'open' command with an excel
> sheet gets me a results window with the correct file name but in both cases
> I can't extract any information from the table.
> I've tried using IJ.renameResults to rename the table as 'Results' but I
> just get the message that it isn't a results window.
>
> does anyone have a suggestion of how to get around this? (or another way to
> open a tab delimited file into a macro accessible format?)
>
> thanks
>
> Adam

George H. Patterson
Building 13 3E33
13 South Drive
Biophotonics Section
National Institute of Biomedical Imaging and Bioengineering
National Institutes of Health
Bethesda, MD 20892
Office: 301-443-0241
Fax: 301-496-6608
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Importing results?

Dr Adam Cliffe
Thanks for the help George,

I've also come across this plugin which does the trick pretty well.
http://imagej.nih.gov/ij/plugins/results-importer/index.html


Regards,

Adam

On Mon, Feb 27, 2012 at 11:20 PM, George Patterson <[hidden email]>wrote:

> Hi Adam,
> I've pasted a part of a macro I've been using below that might help.
> It's not too elegant and I'm sure someone has a better way to do it, but
> it might work until they post a better approach.
> It's slow with large files and I've run into memory problems with files
> >0.5GB.
> At the end you should have a 32-bit image open with each pixel having the
> values in your text.  You should be able to access them with
> selectImage(myInfoFile) and getPixel(x,y).
> Best,
> George
>
> print("\\Clear");
> pathfile=File.openDialog("Choose the file to Open:");
> filestring=File.openAsString(pathfile);
> dir1=File.directory;
> InfoFile=File.nameWithoutExtension;
> print(filestring);
> print("\\Update0:");//replaces in the entries first row (column headers in
> my case), you might want to get rid of this line
> selectWindow("Log");
> saveAs("text", dir1+InfoFile+"_saved"+".txt");
> run("Text Image... ", "open="+dir1+InfoFile+"_saved"+".txt");
> myInfoFile=getImageID();
>
>
>
>
> On Feb 27, 2012, at 12:50 AM, Adam Cliffe wrote:
>
> > Hi,
> >
> > I'm trying to write a macro which will import a tab delimited text file
> or
> > excel sheet and extract some of the values from it.
> > I've tried using the run("Results... ", "open=my file path"); command
> and I
> > get an untitled results window. Using the 'open' command with an excel
> > sheet gets me a results window with the correct file name but in both
> cases
> > I can't extract any information from the table.
> > I've tried using IJ.renameResults to rename the table as 'Results' but I
> > just get the message that it isn't a results window.
> >
> > does anyone have a suggestion of how to get around this? (or another way
> to
> > open a tab delimited file into a macro accessible format?)
> >
> > thanks
> >
> > Adam
>
> George H. Patterson
> Building 13 3E33
> 13 South Drive
> Biophotonics Section
> National Institute of Biomedical Imaging and Bioengineering
> National Institutes of Health
> Bethesda, MD 20892
> Office: 301-443-0241
> Fax: 301-496-6608
> [hidden email]
>