Small bug in import sequence

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

Small bug in import sequence

Stein Rørvik
Hello,

I have encountered what appears to be a small bug in the import Image Sequence command.

What I want to do is to open image number N in a large amount folders to compare these images. The result image title should be named according to the folder name, not the file name, as the file names are the same for all folders. The file name (displaying the number in the sequence) should be set as the image(slice)label.

I thought an easy way to do this would be to use File → Import → Image Sequence and specify N as the starting image and 1 as the number of slices.
That should result in a one-slice stack named the same as the folder, with the file name as the label.

This does not work however; if the number of images is set to 1. The correct file is opened, but the label is set to image 1 in the sequence.
If the number of images is 2 or more, it works as expected.

It also works correctly if the "separate images" option is chosen, but that is not what I want because the result image name will then be equal to the filename not the folder name.

Example macro to reproduce the issue:

dir = "C:/Users/steinr/Temp/";
path = dir + "t1-head/";
File.makeDirectory(path);
run("Close All");

//create sequence
run("T1 Head (16-bits)");
run("Image Sequence... ", "dir=[&path] format=TIFF name=t1-head_ start=1");

//open one slice
run("Image Sequence...", "dir=[&path] start=50 count=1 sort");
//fails, opens image 50 but the label is from image 1

//open two slices
run("Image Sequence...", "dir=[&path] start=50 count=2 sort");
//works, opens image 50 and 51 with correct labels

//open one slice, separate
run("Image Sequence...", "dir=[&path] start=50 count=1 sort open");
//works, opens image 50

//open two slices, separate
run("Image Sequence...", "dir=[&path] start=50 count=2 sort open");
//works, opens image 50 and 51

Stein

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

Re: Small bug in import sequence

Wayne Rasband-2
> On Apr 22, 2021, at 5:41 AM, Stein Rørvik <[hidden email]> wrote:
>
> Hello,
>
> I have encountered what appears to be a small bug in the import Image Sequence command.
>
> What I want to do is to open image number N in a large amount folders to compare these images. The result image title should be named according to the folder name, not the file name, as the file names are the same for all folders. The file name (displaying the number in the sequence) should be set as the image(slice)label.
>
> I thought an easy way to do this would be to use File → Import → Image Sequence and specify N as the starting image and 1 as the number of slices.
> That should result in a one-slice stack named the same as the folder, with the file name as the label.
>
> This does not work however; if the number of images is set to 1.

This bug is fixed in the ImageJ 1.53j24 daily build.

-wayne


> The correct file is opened, but the label is set to image 1 in the sequence.
> If the number of images is 2 or more, it works as expected.
>
> It also works correctly if the "separate images" option is chosen, but that is not what I want because the result image name will then be equal to the filename not the folder name.
>
> Example macro to reproduce the issue:
>
> dir = "C:/Users/steinr/Temp/";
> path = dir + "t1-head/";
> File.makeDirectory(path);
> run("Close All");
>
> //create sequence
> run("T1 Head (16-bits)");
> run("Image Sequence... ", "dir=[&path] format=TIFF name=t1-head_ start=1");
>
> //open one slice
> run("Image Sequence...", "dir=[&path] start=50 count=1 sort");
> //fails, opens image 50 but the label is from image 1
>
> //open two slices
> run("Image Sequence...", "dir=[&path] start=50 count=2 sort");
> //works, opens image 50 and 51 with correct labels
>
> //open one slice, separate
> run("Image Sequence...", "dir=[&path] start=50 count=1 sort open");
> //works, opens image 50
>
> //open two slices, separate
> run("Image Sequence...", "dir=[&path] start=50 count=2 sort open");
> //works, opens image 50 and 51
>
> Stein

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

Re: Small bug in import sequence

Stein Rørvik
Thanks for the fix, it works fine!

I also have a request for a fix to a related issue:

The "Images to Stack" command has an option to use image titles as slice labels. This works as expected. However, if this option is off, one would expect the image labels (if defined) to be preserved as slice labels in the assembled stack. But the image labels are currently ignored. See this demo macro:

run("Close All");

run("Blobs (25K)");
rename("Image 1");
setMetadata("Label", "Label 1");

run("Blobs (25K)");
rename("Image 2");
setMetadata("Label", "Label 2");

//use Title as Labels = on
run("Images to Stack", "name=[Stack 1] title=Image use keep");
//works as expected

//use Title as Labels = off
run("Images to Stack", "name=[Stack 2] title=Image keep");
//image labels are lost, no slice labels in new stack

run("Tile");

Stein

-----Original Message-----
Sent: 25. april 2021 04:28
Subject: Re: Small bug in import sequence

> On Apr 22, 2021, at 5:41 AM, Stein Rørvik <[hidden email]> wrote:
>
> Hello,
>
> I have encountered what appears to be a small bug in the import Image Sequence command.
>
> What I want to do is to open image number N in a large amount folders to compare these images. The result image title should be named according to the folder name, not the file name, as the file names are the same for all folders. The file name (displaying the number in the sequence) should be set as the image(slice)label.
>
> I thought an easy way to do this would be to use File → Import → Image Sequence and specify N as the starting image and 1 as the number of slices.
> That should result in a one-slice stack named the same as the folder, with the file name as the label.
>
> This does not work however; if the number of images is set to 1.

This bug is fixed in the ImageJ 1.53j24 daily build.

-wayne


> The correct file is opened, but the label is set to image 1 in the sequence.
> If the number of images is 2 or more, it works as expected.
>
> It also works correctly if the "separate images" option is chosen, but that is not what I want because the result image name will then be equal to the filename not the folder name.
>
> Example macro to reproduce the issue:
>
> dir = "C:/Users/steinr/Temp/";
> path = dir + "t1-head/";
> File.makeDirectory(path);
> run("Close All");
>
> //create sequence
> run("T1 Head (16-bits)");
> run("Image Sequence... ", "dir=[&path] format=TIFF name=t1-head_
> start=1");
>
> //open one slice
> run("Image Sequence...", "dir=[&path] start=50 count=1 sort");
> //fails, opens image 50 but the label is from image 1
>
> //open two slices
> run("Image Sequence...", "dir=[&path] start=50 count=2 sort");
> //works, opens image 50 and 51 with correct labels
>
> //open one slice, separate
> run("Image Sequence...", "dir=[&path] start=50 count=1 sort open");
> //works, opens image 50
>
> //open two slices, separate
> run("Image Sequence...", "dir=[&path] start=50 count=2 sort open");
> //works, opens image 50 and 51
>
> Stein


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

Re: Small bug in import sequence

Wayne Rasband-2
> On Apr 26, 2021, at 4:28 AM, Stein Rørvik <[hidden email]> wrote:
>
> Thanks for the fix, it works fine!
>
> I also have a request for a fix to a related issue:
>
> The "Images to Stack" command has an option to use image titles as slice labels. This works as expected. However, if this option is off, one would expect the image labels (if defined) to be preserved as slice labels in the assembled stack. But the image labels are currently ignored. See this demo macro:

This bug is fixed in the ImageJ 1.53j25 daily build.

-wayne


>
> run("Close All");
>
> run("Blobs (25K)");
> rename("Image 1");
> setMetadata("Label", "Label 1");
>
> run("Blobs (25K)");
> rename("Image 2");
> setMetadata("Label", "Label 2");
>
> //use Title as Labels = on
> run("Images to Stack", "name=[Stack 1] title=Image use keep");
> //works as expected
>
> //use Title as Labels = off
> run("Images to Stack", "name=[Stack 2] title=Image keep");
> //image labels are lost, no slice labels in new stack
>
> run("Tile");
>
> Stein
>
> -----Original Message-----
> Sent: 25. april 2021 04:28
> Subject: Re: Small bug in import sequence
>
>> On Apr 22, 2021, at 5:41 AM, Stein Rørvik <[hidden email]> wrote:
>>
>> Hello,
>>
>> I have encountered what appears to be a small bug in the import Image Sequence command.
>>
>> What I want to do is to open image number N in a large amount folders to compare these images. The result image title should be named according to the folder name, not the file name, as the file names are the same for all folders. The file name (displaying the number in the sequence) should be set as the image(slice)label.
>>
>> I thought an easy way to do this would be to use File → Import → Image Sequence and specify N as the starting image and 1 as the number of slices.
>> That should result in a one-slice stack named the same as the folder, with the file name as the label.
>>
>> This does not work however; if the number of images is set to 1.
>
> This bug is fixed in the ImageJ 1.53j24 daily build.
>
> -wayne
>
>
>> The correct file is opened, but the label is set to image 1 in the sequence.
>> If the number of images is 2 or more, it works as expected.
>>
>> It also works correctly if the "separate images" option is chosen, but that is not what I want because the result image name will then be equal to the filename not the folder name.
>>
>> Example macro to reproduce the issue:
>>
>> dir = "C:/Users/steinr/Temp/";
>> path = dir + "t1-head/";
>> File.makeDirectory(path);
>> run("Close All");
>>
>> //create sequence
>> run("T1 Head (16-bits)");
>> run("Image Sequence... ", "dir=[&path] format=TIFF name=t1-head_
>> start=1");
>>
>> //open one slice
>> run("Image Sequence...", "dir=[&path] start=50 count=1 sort");
>> //fails, opens image 50 but the label is from image 1
>>
>> //open two slices
>> run("Image Sequence...", "dir=[&path] start=50 count=2 sort");
>> //works, opens image 50 and 51 with correct labels
>>
>> //open one slice, separate
>> run("Image Sequence...", "dir=[&path] start=50 count=1 sort open");
>> //works, opens image 50
>>
>> //open two slices, separate
>> run("Image Sequence...", "dir=[&path] start=50 count=2 sort open");
>> //works, opens image 50 and 51
>>
>> Stein

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