Login  Register

Re: Macro to split images and save as title

Posted by CARL Philippe (LBP) on Jun 11, 2020; 11:47pm
URL: http://imagej.273.s1.nabble.com/Macro-to-split-images-and-save-as-title-tp5023353p5023505.html

Dear Marc,
I'm just before going to sleep and thus will read your mail more deeply and seriously tomorrow morning in order to better understand the description of your first issue (i.e. about file importing).
Nevertheless, your second issue, i.e. the one about the error message you are getting because you are trying to save the following file:
"C:\destinationfolder\C2process_1055 Group:1 Level:1 Area:1.tif"
is trivial and simply due to the fact that you have ':' characters within your filenames which aren't allowed.
Thus in order to fix this, just use the replace(string, old, new) method:
https://imagej.nih.gov/ij/developer/macro/functions.html#replace
in order to replace all your ':' characters by other ones, maybe '_'.
Thus simply replace the following line code I had recommended you some time ago:
save(dir2+substring(getTitle(),0,lastIndexOf(getTitle(),"."))+".tif");
by
save(dir2+replace(substring(getTitle(),0,lastIndexOf(getTitle(),".")),":","_")+".tif");
And you should be all set...
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 42 89

----- Mail original -----
De: "bluebird" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Jeudi 11 Juin 2020 20:40:21
Objet: Re: Macro to split images and save as title

Dear Kees and Philippe

Please accept my apology in replying so late, I got drowned out by another
project. Thank you both very much for your input. I tried out the
suggestions you both made, but the macro seems to get stuck at making the
Viewer open the files. First I'm asked to select source and destination
directory, which works. Immediately following that is a request from the
Olympus Viewer dialogue to open a file (can only select one). If clicking
canncel, this is followed by the error:

There are no images open in line 7
getDimensions(width, height, channels, slices, frames);

When choosing a file (can only click one), the images are split and the
following error appears:

File saving error (IOException)
"C:\destinationfolder\C2process_1055 Group:1 Level:1 Area:1.tif (the
filename, direc"
C:\destinationfolder\C2process_1055 Group:1 Level:1 Area:1.tif

Possibly the error message's first line is supposed to be longer, but it
ends like that.

Thank you in advance for any further help!

Best,
Marc



--
Sent from: http://imagej.1557.x6.nabble.com/

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

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