Hi all,
I've a macro that makes a several directories corresponding to different channels and file types. The images are tifs generated from Micromanager and I'm converting them to Raw files using a derivative of Wayne Rasband's BatchConvert macro (thanks for sharing). The macro was written on a Mac and works well, but when I switch to a Windows machine I get errors when trying to open the files for conversion. I finally traced down the problem causing the bug (or at least the current bug). It seems the file path is different for making directories compared to opening files within those directories. For instance, I can make the directories on Mac and Windows using something like this. dirA="E:/George/20111123_script_tests/"+"Run_06/"; // if "E:/George/20111123_script_tests/" already exists File.makeDirectory(dirA); dirB=dirA+ "FITCOriginalDataFiles/"; File.makeDirectory(dirB); dirC=dirB+"calibration/"; File.makeDirectory(dirC); and end up with this directory "E:/George/20111123_script_tests/Run_06/FITCOriginalDataFiles/calibration/" However, if I try to open a file in this folder using listC=getFileList(dirC); open(dirC+listC[0]); I get this error. //error is "File is not in a supported format, a reader plugin is not available, or it was not found. img_000000000_FITC_000.tif" This happens only on the Windows machines. It works fine on my Mac. Alternatively, if I use this on the Windows, it works just fine. dirC="E:\\George\\20111123_script_tests\\Run_01\\FITCOriginalDataFiles\\calibration\\"; listC=getFileList(dirC); open(dirC+listC[0]); This path comes from using Record Macro. My questions. 1. Is this normal behavior? If so, do I have some folder option messed up? 2. I'm trying to get around this by using replace(string, old, new), but I've not figured it out yet. Any suggestions will be appreciated. 3. The string for the original file directory is passed in an argument from a Micromanager script using the ij.IJ.runMacroFile command and is looks like this "E:/George/20111123_script_tests/Run_06/". Would it be easier to make the changes in the string before passing it to the macro? Here are the versions and machine specs if it matters. //Micromanager 1.4.6 //demo configuration //Windows XP Service Pack 3 //Intel(R) Core(TM)2 CPU //6600 @ 2.4 GHz // 2.39 GHz, 3.49 GB of RAM //Image J 1.46a //Java 1.6.0_20 (32-bit) Thanks for any help. George |
Hi George,
It seems that there is a difference between the two systems for the file separator character ("/" vs "\\", wich is an escaped "\" I think). Try to replace all the occurences of the file separator in your macro by the pre-define File.separator string which will take care of using the right character for each system : http://rsbweb.nih.gov/ij/developer/macro/functions.html#File.separator something like dirA="E:"+File.separator+"George"+File.separator+"20111123_script_tests"+File.separator+"Run_06"+File.separator; File.makeDirectory(dirA); dirB=dirA+"FITCOriginalDataFiles"+File.separator; and so on. Hope this helps, Christophe -- Christophe Leterrier INSERM UMR641 // Ionic channels Lab IFR Jean Roche, Mediterranée University Marseille, France http://www.cleterrier.net Le jeudi 1 décembre 2011 à 16:25, George Patterson a écrit : > Hi all, > I've a macro that makes a several directories corresponding to different channels and file types. The images are tifs generated from Micromanager and I'm converting them to Raw files using a derivative of Wayne Rasband's BatchConvert macro (thanks for sharing). > > The macro was written on a Mac and works well, but when I switch to a Windows machine I get errors when trying to open the files for conversion. > I finally traced down the problem causing the bug (or at least the current bug). It seems the file path is different for making directories compared to opening files within those directories. > > For instance, I can make the directories on Mac and Windows using something like this. > > dirA="E:/George/20111123_script_tests/"+"Run_06/"; // if "E:/George/20111123_script_tests/" already exists > File.makeDirectory(dirA); > dirB=dirA+ "FITCOriginalDataFiles/"; > File.makeDirectory(dirB); > dirC=dirB+"calibration/"; > File.makeDirectory(dirC); > and end up with this directory > "E:/George/20111123_script_tests/Run_06/FITCOriginalDataFiles/calibration/" > > However, if I try to open a file in this folder using > listC=getFileList(dirC); > open(dirC+listC[0]); > I get this error. > //error is "File is not in a supported format, a reader plugin is not available, or it was not found. img_000000000_FITC_000.tif" > > This happens only on the Windows machines. It works fine on my Mac. > > Alternatively, if I use this on the Windows, it works just fine. > dirC="E:\\George\\20111123_script_tests\\Run_01\\FITCOriginalDataFiles\\calibration\\"; > listC=getFileList(dirC); > open(dirC+listC[0]); > This path comes from using Record Macro. > > My questions. > 1. Is this normal behavior? If so, do I have some folder option messed up? > 2. I'm trying to get around this by using replace(string, old, new), but I've not figured it out yet. > Any suggestions will be appreciated. > 3. The string for the original file directory is passed in an argument from a Micromanager script using the ij.IJ.runMacroFile command and is looks like this "E:/George/20111123_script_tests/Run_06/". > Would it be easier to make the changes in the string before passing it to the macro? > > Here are the versions and machine specs if it matters. > > //Micromanager 1.4.6 > //demo configuration > > //Windows XP Service Pack 3 > //Intel(R) Core(TM)2 CPU > //6600 @ 2.4 GHz > // 2.39 GHz, 3.49 GB of RAM > > //Image J 1.46a > //Java 1.6.0_20 (32-bit) > > > Thanks for any help. > George > > |
Hi Christophe,
Sorry for the late reply. File.separator did the trick. Thanks for the help. Here's a post that I missed in which Wayne Rasband explains that "\\" is the right one for Windows. It looks like you are correct about the escape character "\". George http://imagej.588099.n2.nabble.com/isMacintosh-boolean-in-a-macro-tt1319547.html#a1319937 On Dec 1, 2011, at 10:50 AM, Christophe Leterrier wrote: > Hi George, > > It seems that there is a difference between the two systems for the file separator character ("/" vs "\\", wich is an escaped "\" I think). > > Try to replace all the occurences of the file separator in your macro by the pre-define File.separator string which will take care of using the right character for each system : > http://rsbweb.nih.gov/ij/developer/macro/functions.html#File.separator > > something like > > dirA="E:"+File.separator+"George"+File.separator+"20111123_script_tests"+File.separator+"Run_06"+File.separator; > File.makeDirectory(dirA); > dirB=dirA+"FITCOriginalDataFiles"+File.separator; > > and so on. > > Hope this helps, > > Christophe > > -- > Christophe Leterrier > INSERM UMR641 // Ionic channels Lab > IFR Jean Roche, Mediterranée University > Marseille, France > http://www.cleterrier.net > > Le jeudi 1 décembre 2011 à 16:25, George Patterson a écrit : > >> Hi all, >> I've a macro that makes a several directories corresponding to different channels and file types. The images are tifs generated from Micromanager and I'm converting them to Raw files using a derivative of Wayne Rasband's BatchConvert macro (thanks for sharing). >> >> The macro was written on a Mac and works well, but when I switch to a Windows machine I get errors when trying to open the files for conversion. >> I finally traced down the problem causing the bug (or at least the current bug). It seems the file path is different for making directories compared to opening files within those directories. >> >> For instance, I can make the directories on Mac and Windows using something like this. >> >> dirA="E:/George/20111123_script_tests/"+"Run_06/"; // if "E:/George/20111123_script_tests/" already exists >> File.makeDirectory(dirA); >> dirB=dirA+ "FITCOriginalDataFiles/"; >> File.makeDirectory(dirB); >> dirC=dirB+"calibration/"; >> File.makeDirectory(dirC); >> and end up with this directory >> "E:/George/20111123_script_tests/Run_06/FITCOriginalDataFiles/calibration/" >> >> However, if I try to open a file in this folder using >> listC=getFileList(dirC); >> open(dirC+listC[0]); >> I get this error. >> //error is "File is not in a supported format, a reader plugin is not available, or it was not found. img_000000000_FITC_000.tif" >> >> This happens only on the Windows machines. It works fine on my Mac. >> >> Alternatively, if I use this on the Windows, it works just fine. >> dirC="E:\\George\\20111123_script_tests\\Run_01\\FITCOriginalDataFiles\\calibration\\"; >> listC=getFileList(dirC); >> open(dirC+listC[0]); >> This path comes from using Record Macro. >> >> My questions. >> 1. Is this normal behavior? If so, do I have some folder option messed up? >> 2. I'm trying to get around this by using replace(string, old, new), but I've not figured it out yet. >> Any suggestions will be appreciated. >> 3. The string for the original file directory is passed in an argument from a Micromanager script using the ij.IJ.runMacroFile command and is looks like this "E:/George/20111123_script_tests/Run_06/". >> Would it be easier to make the changes in the string before passing it to the macro? >> >> Here are the versions and machine specs if it matters. >> >> //Micromanager 1.4.6 >> //demo configuration >> >> //Windows XP Service Pack 3 >> //Intel(R) Core(TM)2 CPU >> //6600 @ 2.4 GHz >> // 2.39 GHz, 3.49 GB of RAM >> >> //Image J 1.46a >> //Java 1.6.0_20 (32-bit) >> >> >> Thanks for any help. >> George > George H. Patterson Building 13 3E33 13 South Drive Biophotonics Section National Institute of Biomedical Imaging and Bioengineering National Institutes of Health Bethesda, MD 20892 Office: 301-443-0241 Fax: 301-496-6608 [hidden email] |
Free forum by Nabble | Edit this page |