I wonder if this would be a useful improvement.
This already works: When converting images to stack one can use the image name to be kept as a slice label. When converting a stack to images the images take the name of the label if it exists. But when duplicating a single slice from a stack, the title of the resulting image is derived from that of the stack, not the slice label, and unfortunately the slice label is lost. I wonder if it would be useful to add an option to use the original slice label when one only duplicating a single slice. Or maybe this can be done already? Cheers Gabriel -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In the macro language I think this is what you are looking for.
slice = getSliceNumber(); // for hyperstacks use Stack.getPosition(channel, slice, frame); run("Duplicate...", getTitle()); rename("s"+slice+" " + getTitle()); ========================================================================= Michael Cammer, Microscopy Core & Skirball Institute, NYU Langone Medical Center Cell: 914-309-3270 ** Office: Skirball 2nd Floor main office, back right ** http://ocs.med.nyu.edu/microscopy & http://microscopynotes.com/ -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Gabriel Landini Sent: Wednesday, May 25, 2016 7:59 AM To: [hidden email] Subject: Name of duplicated slice from a stack I wonder if this would be a useful improvement. This already works: When converting images to stack one can use the image name to be kept as a slice label. When converting a stack to images the images take the name of the label if it exists. But when duplicating a single slice from a stack, the title of the resulting image is derived from that of the stack, not the slice label, and unfortunately the slice label is lost. I wonder if it would be useful to add an option to use the original slice label when one only duplicating a single slice. Or maybe this can be done already? Cheers Gabriel -- ImageJ mailing list: https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.nih.gov_ij_list.html&d=CwICAg&c=j5oPpO0eBH1iio48DtsedbOBGmuw5jHLjgvtN2r4ehE&r=oU_05LztNstAydlbm5L5GDu_vAdjXk3frDLx_CqKkuo&m=ejm0elOH9c16HSzalbByLQ0kntmMmYp6D6SN08rfpi4&s=lf4TgnArSm7pkHmZcR9WIQFKOM4uWkeTG3eEdwvsZJ0&e= ------------------------------------------------------------ This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email. ================================= -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
On Wednesday 25 May 2016 14:45:25 Cammer, Michael wrote:
> slice = getSliceNumber(); > // for hyperstacks use Stack.getPosition(channel, slice, frame); > run("Duplicate...", getTitle()); > rename("s"+slice+" " + getTitle()); Thanks Michael, but that does not do it. I am suggesting an option in the Duplicate dialog that when ticked, it does this: slice =getMetadata("Label"); run("Duplicate...", getTitle()); if(slice!="") rename(slice); Even if this is doable as a macro, it is not very practical interactively (we need to run a macro each time we to duplicate a slice). Cheers Gabriel -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Gabriel Landini
Hi Gabriel,
you can have it with a macro: //create a stack for testing (no images should be open) run("Blobs (25K)"); run("Duplicate...", "title=whiteBlobs"); run("Invert"); run("Images to Stack", "name=Stack title=[] use"); //duplicate a slice, then rename it according to the label: //setSlice(2); if desired label = getInfo("slice.label"); run("Duplicate...", " "); if (label != "") rename(label); Nevertheless, I agree that it would be handy to have a checkbox 'Image name from slice label' or so, in case a stack gets duplicated. The checkbox could get grayed out when 'Duplicate stack' gets selected. Possibly more elegant: Automatically suggesting the slice label as a name when duplicating a stack and switching to something like 'stackName-1' when the user clicks 'Duplicate stack'. Typing something into the 'Title' field should disable the automatic title generation. Michael ________________________________________________________________ On 2016-05-25 13:59, Gabriel Landini wrote: > I wonder if this would be a useful improvement. > > This already works: > When converting images to stack one can use the image name to be kept as a > slice label. > When converting a stack to images the images take the name of the label if it > exists. > > But when duplicating a single slice from a stack, the title of the resulting > image is derived from that of the stack, not the slice label, and > unfortunately the slice label is lost. > > I wonder if it would be useful to add an option to use the original slice > label when one only duplicating a single slice. > > Or maybe this can be done already? > > Cheers > > Gabriel > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Gabriel Landini
Gabriel,
I think you are right that having built-in flexibility in labeling duplicated images as an alternative to running a macro would be a useful time and effort saver. A related thought regarding duplication of image windows, though not specific to image stack windows: If I open a TIFF image or save a new image window as a TIFF, the title of the window then includes the ".tif" extension (on my MacOS 10 machines). Apart from metadata that is specific to TIFF format files of for reminding the user that the image exists as a stored file, I don't see why indicating the file format in the window title really pertains to an open image window. And since the default "Save"behavior for image windows is to use TIFF format, I don't see any gain for ImageJ in maintaining the ".tif" extension in the window title or loss if this extension is eliminated. I often then use a function to remove a file extension from a window name, like this: dotIndex = indexOf(oName, "."); if (dotIndex >= 0) nName = substring(oName, 0, dotIndex); rename(nName); If a window name might have multiple "." characters in it (I've prevented this possibility elsewhere in my code), then a test for this is needed. It might be good to have a persistent option to automatically suppress the ".tif" extension (and perhaps all extensions) from window titles. Bill Christens-Barry -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Bill,
> If a window name might have multiple "." characters in it (I've > prevented this possibility elsewhere in my code), then a test for > this is needed. Instead of using "indexOf" you can use "lastIndexOf" which is a more robust way to get the file extension. The only issue then is for file extensions which themselves use a dot, e.g. ".ome.tif", but in most cases you do not need to worry about these. See also the "File.nameWithoutExtension" macro function. Regards, Curtis -- Curtis Rueden LOCI software architect - http://loci.wisc.edu/software ImageJ2 lead, Fiji maintainer - http://imagej.net/User:Rueden Did you know ImageJ has a forum? http://forum.imagej.net/ On Wed, May 25, 2016 at 1:22 PM, Bill Christens-Barry <[hidden email]> wrote: > Gabriel, > > I think you are right that having built-in flexibility in labeling > duplicated images as an alternative to running a macro would be a useful > time and effort saver. > > A related thought regarding duplication of image windows, though not > specific to image stack windows: > > If I open a TIFF image or save a new image window as a TIFF, the title of > the window then includes the ".tif" extension (on my MacOS 10 machines). > Apart from metadata that is specific to TIFF format files of for reminding > the user that the image exists as a stored file, I don't see why indicating > the file format in the window title really pertains to an open image > window. And since the default "Save"behavior for image windows is to use > TIFF format, I don't see any gain for ImageJ in maintaining the ".tif" > extension in the window title or loss if this extension is eliminated. > > I often then use a function to remove a file extension from a window name, > like this: > > dotIndex = indexOf(oName, "."); > if (dotIndex >= 0) > nName = substring(oName, 0, dotIndex); > rename(nName); > > If a window name might have multiple "." characters in it (I've prevented > this possibility elsewhere in my code), then a test for this is needed. > > It might be good to have a persistent option to automatically suppress the > ".tif" extension (and perhaps all extensions) from window titles. > > Bill Christens-Barry > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Gabriel Landini
Curtis,
Thanks for the tip regarding File.nameWithoutExtension(), which I did not know about. Agreed, lastIndexOf() is an improved way to isolate just the extension. Bill Christens-Barry -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Gabriel Landini
> On May 25, 2016, at 7:46 AM, Gabriel Landini <[hidden email]> wrote: > > I wonder if this would be a useful improvement. > > This already works: > When converting images to stack one can use the image name to be kept as a > slice label. > When converting a stack to images the images take the name of the label if it > exists. > > But when duplicating a single slice from a stack, the title of the resulting > image is derived from that of the stack, not the slice label, and > unfortunately the slice label is lost. > > I wonder if it would be useful to add an option to use the original slice > label when one only duplicating a single slice. > > Or maybe this can be done already? You can do this if you upgrade to the latest ImageJ daily build (1.51b19). When using Image>Duplicate, the title of the resulting image is automatically derived from the slice label. To provide backward compatibility, the recorder generates run("Duplicate...", "use"); where ‘use' indicates that the slice label is to be used. Previous versions of ImageJ generated run("Duplicate...", " "); which uses the stack name plus “-n” as the suggested title of the resulting image. -wayne -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Kudos, Wayne and Gabriel! I've been adding the slice label by hand all along and didn't think to ask for the change.
Michael ________________________________________ From: ImageJ Interest Group [[hidden email]] on behalf of Rasband, Wayne (NIH/NIMH) [E] [[hidden email]] Sent: Monday, May 30, 2016 00:07 To: [hidden email] Subject: Re: Name of duplicated slice from a stack > On May 25, 2016, at 7:46 AM, Gabriel Landini <[hidden email]> wrote: > > I wonder if this would be a useful improvement. > > This already works: > When converting images to stack one can use the image name to be kept as a > slice label. > When converting a stack to images the images take the name of the label if it > exists. > > But when duplicating a single slice from a stack, the title of the resulting > image is derived from that of the stack, not the slice label, and > unfortunately the slice label is lost. > > I wonder if it would be useful to add an option to use the original slice > label when one only duplicating a single slice. > > Or maybe this can be done already? You can do this if you upgrade to the latest ImageJ daily build (1.51b19). When using Image>Duplicate, the title of the resulting image is automatically derived from the slice label. To provide backward compatibility, the recorder generates run("Duplicate...", "use"); where ‘use' indicates that the slice label is to be used. Previous versions of ImageJ generated run("Duplicate...", " "); which uses the stack name plus “-n” as the suggested title of the resulting image. -wayne -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |