Login  Register

Re: Saving the current session

Posted by Jerome Mutterer-3 on Nov 05, 2013; 11:25pm
URL: http://imagej.273.s1.nabble.com/Saving-the-current-session-tp5005456p5005462.html

Hi Michael,
The 'Workspaces' macro does basically the same thing, and allows to keep
multiple workspaces (or sessions) and restore them. It has the same
limitations that you raised.

see http://rsb.info.nih.gov/ij/macros/Workspaces.txt

Jerome



On 5 November 2013 18:37, Michael Schmid <[hidden email]> wrote:

> Hi everyone,
>
> does someone out there have a plugin to save the current ImageJ session to
> disk?  It need not be perfect (I don't care about placing windows to the
> correct position, etc.)...
>
> I tried a simple macro approach (below), but I got stuck:
> - 'Save as zip' does not save FFT data of FFT windows
> - No way to determine in a macro whether the front window is a text or
> Results window.  [getInfo("window.contents") gives unpredictable results if
> the front window is neither image nor text]
> - Plots won't have data behind them (that's a restriction I could live
> with).
>
> Long time ago, this topic was already discussed on the mailinglist, and it
> was suggested to have the ImageJ data types implement Serializable.  Is I
> understand it, however, this would imply the risk that one can't read the
> session after updating ImageJ, which is also not so nice...
>
> Michael
> ________________________________________________________________
>
> // SaveSession macro
> // Saves images and more of an ImageJ session
> // V0.0 M. Schmid 2013-11-05
> //
> // Restrictions (there are actually more):
> // Images do not remember the source file
> // FFTs are saved as plain 8-bit images (no Fourier transform behind,
> can't do inverse FFT)
> // Plots are saved as images with no data
> // What about texts?
> // How to discriminate ResultsTables and text with tabs?
> // Settings are not saved (ImageJ saves some settings to the ijPrefs.txt
> file)
> //
> basePath=getDirectory("Choose a Directory to Save the Session");
> getDateAndTime(year, month, dayOfWeek, dayOfMonth, hour, minute, second,
> msec);
> date= dayOfMonth+100*(month+1)+10000* dayOfMonth;
> time=second+100* minute+10000*hour;
> dirName="IJsavedSession_"+date+"_"+IJ.pad(time,6);
> path=basePath+File.separator+dirName;
> File.makeDirectory(path);
> // ----------------- Images -----------------
> while(nImages()>0) {
>   selectImage(1);
>   fileNoExt=path+File.separator+getTitle;
>   uniqueNum="";
>   while (File.exists(fileNoExt+uniqueNum +".zip")) {
>     if (uniqueNum="") uniqueNum="0";
>     uniqueNum = toString(parseInt(uniqueNum)-1); //-1, -2, etc.
>   }
>   save(fileNoExt+uniqueNum+".zip");
>   close();
> }
> // ----------------- Log Window -----------------
> logText=getInfo("log");
> if(logText!="") {
>   File.saveString(logText, path+File.separator+"log.txt");
>   selectWindow("Log");
>   run("Close");
> }
>
> // ----------------- ROI Manager -----------------
> nRois=roiManager("count");
> if (nRois>0) {
>   roiManager("Save", path+File.separator+"roiSet.zip");
>   selectWindow("ROI Manager");
>   run("Close");
> }
> // ----------------- Results -----------------
> if (nResults>0) {
>   saveAs("results",  path+File.separator+"resultsTable.csv");
> }
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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