Posted by
CARL Philippe (LBP) on
Oct 28, 2019; 1:08pm
URL: http://imagej.273.s1.nabble.com/selectWindow-does-not-work-tp5022577p5022595.html
Dear Herbie,
In fact to use the indexOf method is as well dangerous in the case there are "." within the file name (which is fully allowed) and thus it is even better to use the lastIndexOf method.
imgTitle="191014_Hela_5min.czi"
print("c:1/2 - " + substring(imgTitle, 0, lastIndexOf(imgTitle, ".")));
FYI in the case there are indeed "." within the picture file name your method using the split won't be working as well...
Have a nice day,
Philippe
PS: As well FYI coming from "Elsass", I learned to speak German way before French...
Philippe CARL
Laboratoire de Bioimagerie et Pathologies
UMR 7021 CNRS - Université de Strasbourg
Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 41 84
----- Mail original -----
De: "CARL Philippe (LBP)" <
[hidden email]>
À: "imagej" <
[hidden email]>
Envoyé: Lundi 28 Octobre 2019 13:34:23
Objet: Re: selectWindow does not work
Dear Herbie,
In this case just use the substring and indexOf methods:
imgTitle="191014_Hela_5min.czi"
print("c:1/2 - " + substring(imgTitle, 0, indexOf(imgTitle, ".")));
Kindest regards,
Philippe
----- Mail original -----
De: "Herbie" <
[hidden email]>
À: "imagej" <
[hidden email]>
Envoyé: Lundi 28 Octobre 2019 12:04:19
Objet: Re: selectWindow does not work
Merci Philippe,
pour ta suggestion!
I don't like substring for this purpose because there are file suffixes
containing more than 3 chars...
A la prochaine
Herbie
:::::::::::::::::::::::::::::::::::::::::::::::::
Am 28.10.19 um 11:55 schrieb CARL Philippe (LBP):
> Gruss Gott Herbie and dear Kerstin,
> Your code below will be working, there is no issue about this.
> Nevertheless, I think it is somehow over killing to use a split function simply in order to reduce the size of a String.
> I say this given especially that you need then two lines in order to get your results.
> Thus why not simply use of the substring method within the following code?:
> imgTitle="191014_Hela_5min.czi"
> print("c:1/2 - " + substring(imgTitle, 0, lengthOf(imgTitle) - 4));
> My best regards,
> Philippe
>
> Philippe CARL
> Laboratoire de Bioimagerie et Pathologies
> UMR 7021 CNRS - Université de Strasbourg
> Faculté de Pharmacie
> 74 route du Rhin
> 67401 ILLKIRCH
> Tel : +33(0)3 68 85 41 84
>
> ----- Mail original -----
> De: "Herbie" <
[hidden email]>
> À: "imagej" <
[hidden email]>
> Envoyé: Lundi 28 Octobre 2019 11:07:28
> Objet: Re: selectWindow does not work
>
> Thanks for the details Kerstin!
>
> Please run the following test-macro.
> (Copy the macro code lines to an empty macro window
> "Plugins >> New >> Macro" and run it.)
> ////
> imgTitle="191014_Hela_5min.czi"; // name of the open stack
> nme=split(imgTitle, ".");
> print("c:1/2 - "+nme[0]);
> ////
>
> For me the Log-window then shows the string:
> c:1/2 - 191014_Hela_5min
> which should be the title of the desired image after calling
> run("Stack to Images");
>
> Please confirm that the Log-window shows the correct name of the image.
>
> Regards
>
> Herbie
>
> ::::::::::::::::::::::::::::::::::
> Am 28.10.19 um 10:52 schrieb kefe:
>> Hello,
>>
>> the name of the image is in general the date-cellline-time.czi for example:
>> 191014_Hela_5min.czi optionally.nd2
>>
>> well, the files are saved like this by the microscope and I dont think I
>> have any possibility to change it.
>>
>> Best,
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html