File Saving Error IOException with a Mac Computer

Hi,

I have a student that is working on a Mac computer trying to run a code the lab has developed for image saving. We are continuing to get this error message:

It says, "File Saving Error (IOException)

The original code is pasted below.

We appreciate any insight and are thankful for your comments.

Kelly

imageTitle=getTitle();
selectWindow(imageTitle);
print(imageTitle);
roiManager("Select", 0);
run("Copy");
run("Internal Clipboard");
//saveAs("Tiff", "/Macintosh HD/Users/madisonrogers/Desktop/Split/R_CN_"+imageTitle);
close();
selectWindow(imageTitle);
roiManager("Select", 1);
run("Copy");
run("Internal Clipboard");
saveAs("Tiff", "/Macintosh HD/Users/madisonrogers/Desktop/Split/L_CN_"+imageTitle);
close();
selectWindow(imageTitle);
roiManager("Select", 2);
run("Copy");
run("Internal Clipboard");
saveAs("Tiff", "/Macintosh HD/Users/madisonrogers/Desktop/Split/R_LC_"+imageTitle);
close();
selectWindow(imageTitle);
roiManager("Select", 3);
run("Copy");
run("Internal Clipboard");
saveAs("Tiff", "/Macintosh HD/Users/madisonrogers/Desktop/Split/L_LC_"+imageTitle);
close();
numROI=roiManager("count");
print(numROI);
selectWindow(imageTitle);
roiManager("Select", 4);
run("Copy");
run("Internal Clipboard");
if (numROI>5) {
saveAs("Tiff", "/Macintosh HD/Users/madisonrogers/Desktop/Split/R_DC_"+imageTitle);
close();
selectWindow(imageTitle);
roiManager("Select", 5);
run("Copy");
run("Internal Clipboard");
saveAs("Tiff", "/Macintosh HD/Users/madisonrogers/Desktop/Split/L_DC_"+imageTitle);
close();
}
else {
saveAs("Tiff", "/Macintosh HD/Users/madisonrogers/Desktop/Split/DC_"+imageTitle);
close();

}

I suspect a peculiar title. What is the imageTitle?
On a mac, C:/ is strange as it points to a Windows computer disk drive.

Macintosh names for user directories should start with /Users, like /Users/madisonrogers/ so the proper name will be /Users/madisonrogers/Desktop

The path given by the error looks completely different from the one in the macro.
Why is the first saveAs commented out?
In my view, the Copy is not used.

Easiest would be to use ImageJ1’s Debug funtion. Open ImageJ1, load your macro, choose Debug Macro, then single step through the code, meanwhile keeping an eye on the variables, in particular imageTitle.

Apart from that, I would put all split names in an array and loop over the ROIs and the array to save the ROIs as separate files. This makes your macro clearer and shorter.

baseName = getTitle;
baseFolder = "/Users/madisonrogers/Desktop";
splitNames = newArray("R_CN","L_CN_","R_LC","L_LC_","R_DC_","L_DC_","DC_");
for(sn = 0; sn < splitNames.length;sn++){
	roiManager("select",sn);
	fileName = baseFolder + File.separator + splitNames[sn]+baseName;
	run("Duplicate...", "title=");
	saveAs ("tiff", fileName);
	close;
}

The error also indicates a Read Only file; is the user madisonrogers allowed to write files to the Desktop folder? (go to the user folder