open files error

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

open files error

vivace219
Hi. I'm currently trying to write a macros script for Image J that would read the .rawl files for each folder. The code is below.

file1head = "K:\\MicroCT Images\\5-25-09\\C00";

print("i'm the new head "+file1head);
file1tail = ".0000.rawl image=[16-bit Signed] width=512 height=512 offset=0 number=1 gap=0 little-endian open";
starter = 2522;
numFiles = 5;

for(i = 0; i < numFiles; i++){
counter =starter+i;
recounter = toString(counter);
print(recounter);
file1 = file1head+counter+"\\C00"+counter+file1tail;
print(file1);
filechecker = file1head+counter+"\\C00"+counter+".0000.rawl";

tempend = "C:\\Users\\yl49\\Desktop\\temp\\C00";
print("i'm here"+filechecker);
if(File.exists(filechecker)){
        print("i got in"+file1);
        run("Raw...", "open="+file1);
        run("Brightness/Contrast...");
        setMinAndMax(-988, 2136);
        file2 = file1head+counter+".tif";
        tempfile = tempend +counter+".tif";
        print(file2);
        run("Save", "save="+tempfile);
        close();
}

else{
        print("This folder's empty! No starter file! Check Folder!");
}

}




The problem i'm seeing with this code is that when attempting to open the specified file, it also attempts to open other folders that were included in the main K:\\ directory. Then my results show a stack of only 4 images that are of very blurry and messed up material and don't show anything at all. I'm not sure what's wrong with the opening of the files. Can someone shed some light on this?

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: open files error

dscho
Hi,

On Thu, 4 Jun 2009, vivace219 wrote:

> Hi. I'm currently trying to write a macros script for Image J that would
> read the .rawl files for each folder. The code is below.
>
> file1head = "K:\\MicroCT Images\\5-25-09\\C00";

I think the space is the culprit.  You need to enclose filename in
brackets just like you did it with the type parameter:

> file1tail = ".0000.rawl image=[16-bit Signed] width=512 height=512 offset=0

Hth,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: open files error

vivace219
Hi Thanks. Actually I just changed the file name to get rid of the space in "MicroCT Images." However, does anyone know if you make comments in the image j macros editing interface? I'd like to have some of the print statements I wrote to continue to exist but just be commented out so they won't run unless I decide to un-comment them and run them. Thanks.
Johannes Schindelin wrote
Hi,

On Thu, 4 Jun 2009, vivace219 wrote:

> Hi. I'm currently trying to write a macros script for Image J that would
> read the .rawl files for each folder. The code is below.
>
> file1head = "K:\\MicroCT Images\\5-25-09\\C00";

I think the space is the culprit.  You need to enclose filename in
brackets just like you did it with the type parameter:

> file1tail = ".0000.rawl image=[16-bit Signed] width=512 height=512 offset=0

Hth,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: open files error

Michael Schmid
Hi,

it's like in Java or C++:

You can use double slashes for comments:  // a comment till the end  
of the line
An alternative is: /* also a comment */

Funny that I did not find this in the documentation on the ImageJ web  
site.

Michael
________________________________________________________________

On 10 Jun 2009, at 15:31, vivace219 wrote:

> Hi Thanks. Actually I just changed the file name to get rid of the  
> space in
> "MicroCT Images." However, does anyone know if you make comments in  
> the
> image j macros editing interface? I'd like to have some of the print
> statements I wrote to continue to exist but just be commented out  
> so they
> won't run unless I decide to un-comment them and run them. Thanks.
>
> Johannes Schindelin wrote:
>>
>> Hi,
>>
>> On Thu, 4 Jun 2009, vivace219 wrote:
>>
>>> Hi. I'm currently trying to write a macros script for Image J  
>>> that would
>>> read the .rawl files for each folder. The code is below.
>>>
>>> file1head = "K:\\MicroCT Images\\5-25-09\\C00";
>>
>> I think the space is the culprit.  You need to enclose filename in
>> brackets just like you did it with the type parameter:
>>
>>> file1tail = ".0000.rawl image=[16-bit Signed] width=512 height=512
>>> offset=0
>>
>> Hth,
>> Dscho
>>
>>
>