Voxel depth not saved?

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

Voxel depth not saved?

vischer
Hello,

in the following macro, I found that the voxel depth is not saved.
(And by the way, why does the "delete file" instruction return zero ?)
Running on OS X.


run("Close All");
print("\\Clear");
path = getDirectory("temp") + "ABC";
newImage("ABC", "8-bit color-mode label", 400, 300, 3, 3, 5);
setVoxelSize(0.5, 0.5, 0, "um");
getVoxelSize(width, height, depth, unit);
print("voxelDepth = ", depth, "  expected: 0");
saveAs("Tiff", path);
run("Revert");
deleted = File.delete(path);
print("deleted = ", deleted, "  expected: 1" );
print("file exists = ", File.exists(path), "  expected: 0" );
getVoxelSize(width, height, depth, unit);
print("voxelDepth = ", depth, "  expected: 0");



output:
=======
voxelDepth =  0   expected: 0
deleted =  0   expected: 1
file exists =  0   expected: 0
voxelDepth =  1   expected: 0



Norbert Vischer

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

Re: Voxel depth not saved?

Rasband, Wayne (NIH/NIMH) [E]
On Jan 30, 2014, at 6:26 PM, Norbert Vischer wrote:

> Hello,
>
> in the following macro, I found that the voxel depth is not saved.
> (And by the way, why does the "delete file" instruction return zero ?)
> Running on OS X.

Voxel depths of zero are not saved. You can work around this problem by using a value near zero, such as 1e-39. File.delete() returns zero because saveAs("Tiff",path) changes the file name from "ABC" to "ABC.tif".

-wayne

> run("Close All");
> print("\\Clear");
> path = getDirectory("temp") + "ABC";
> newImage("ABC", "8-bit color-mode label", 400, 300, 3, 3, 5);
> setVoxelSize(0.5, 0.5, 0, "um");
> getVoxelSize(width, height, depth, unit);
> print("voxelDepth = ", depth, "  expected: 0");
> saveAs("Tiff", path);
> run("Revert");
> deleted = File.delete(path);
> print("deleted = ", deleted, "  expected: 1" );
> print("file exists = ", File.exists(path), "  expected: 0" );
> getVoxelSize(width, height, depth, unit);
> print("voxelDepth = ", depth, "  expected: 0");
>
> output:
> =======
> voxelDepth =  0   expected: 0
> deleted =  0   expected: 1
> file exists =  0   expected: 0
> voxelDepth =  1   expected: 0
>
> Norbert Vischer

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

Re: Voxel depth not saved?

vischer
Hi Wayne,


> Voxel depths of zero are not saved. You can work around this problem by using a value near zero, such as 1e-39. File.delete() returns zero because saveAs("Tiff",path) changes the file name from "ABC" to "ABC.tif".
>
> -wayne


thanks for this information. As this behaviour has not changed in the newest version, I assume there is some technical reason for it.

In this context, I noticed that "Set Scale.." silently changes the voxel depth, assuming that voxels are cubic by default (see macro below).
In none of my confocal 3D images voxels were ever cubic, and changing some invisible parameter is not good anyway. My suggestion is not to change the voxel depth automatically.

best regards, Norbert




newImage("ABC.tif", "8-bit white", 400, 400, 2);
run("Properties...", "voxel_depth=0.7");
getVoxelSize(width, height, depth, unit);
print("\\Clear");
print("voxel depth = ", depth);
run("Set Scale...", "distance=8 known=1 unit=um");//also changes voxe
getVoxelSize(width, height, depth, unit);
print("voxel depth = ", depth);

output:
=======
voxel depth =  0.7
voxel depth =  0.125

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