Search in sources :

Example 1 with LocalWorkspace

use of cbit.vcell.microscopy.LocalWorkspace in project vcell by virtualcell.

the class FRAPBatchRunWorkspace method getLoadSingleFilesTask.

// get client task for loading each single vfrap files in a batch run
public AsynchClientTask getLoadSingleFilesTask(LocalWorkspace arg_localWorkspace) {
    final LocalWorkspace localWorkspace = arg_localWorkspace;
    AsynchClientTask openSingleFilesTask = new AsynchClientTask("", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        public void run(Hashtable<String, Object> hashTable) throws Exception {
            FRAPBatchRunWorkspace tempBatchRunWorkspace = (FRAPBatchRunWorkspace) hashTable.get(BATCH_RUN_WORKSPACE_KEY);
            if (tempBatchRunWorkspace != null) {
                ArrayList<FRAPStudy> fStudyList = tempBatchRunWorkspace.getFrapStudies();
                int size = fStudyList.size();
                for (int i = 0; i < size; i++) {
                    String fileName = fStudyList.get(i).getXmlFilename();
                    File fStudyFile = new File(fileName);
                    if (// .vfrap
                    fileName.endsWith("." + VirtualFrapLoader.VFRAP_EXTENSION) || fileName.endsWith(".xml")) {
                        this.getClientTaskStatusSupport().setMessage("Loading(.vfrap) " + (i + 1) + " of " + size + " : " + fileName);
                        FRAPStudy newFRAPStudy = null;
                        String xmlString = XmlUtil.getXMLString(fStudyFile.getAbsolutePath());
                        MicroscopyXmlReader xmlReader = new MicroscopyXmlReader(true);
                        newFRAPStudy = xmlReader.getFrapStudy(XmlUtil.stringToXML(xmlString, null).getRootElement(), this.getClientTaskStatusSupport());
                        // if((newFRAPStudy.getFrapDataExternalDataInfo() != null || newFRAPStudy.getRoiExternalDataInfo() != null) &&
                        // !FRAPWorkspace.areExternalDataOK(localWorkspace,newFRAPStudy.getFrapDataExternalDataInfo(),newFRAPStudy.getRoiExternalDataInfo()))
                        // {
                        // throw new Exception("External Files of Frap Document " + fStudyFile.getAbsolutePath() + " are corrupted");
                        // }
                        newFRAPStudy.setXmlFilename(fileName);
                        // get dimentsion reduced experimental data
                        newFRAPStudy.getDimensionReducedExpData();
                        // restore the dimension reduced fitting data(2 dimensional array).
                        int selectedModelIdx = tempBatchRunWorkspace.getSelectedModel();
                        FRAPModel frapModel = newFRAPStudy.getFrapModel(selectedModelIdx);
                        // optimization was done but data wasn't save with file, need to restore data
                        if (frapModel != null && frapModel.getModelParameters() != null && frapModel.getModelParameters().length > 0 && frapModel.getData() == null) {
                            if (frapModel.getModelIdentifer().equals(FRAPModel.MODEL_TYPE_ARRAY[FRAPModel.IDX_MODEL_REACTION_OFF_RATE])) {
                                FRAPOptFunctions frapOptFunc = new FRAPOptFunctions(newFRAPStudy);
                                newFRAPStudy.setFrapOptFunc(frapOptFunc);
                                frapModel.setData(frapOptFunc.getFitData(frapModel.getModelParameters()));
                            } else {
                                FRAPOptData optData = new FRAPOptData(newFRAPStudy, frapModel.getModelParameters().length, localWorkspace, newFRAPStudy.getStoredRefData());
                                newFRAPStudy.setFrapOptData(optData);
                                frapModel.setData(optData.getFitData(frapModel.getModelParameters()));
                            }
                        }
                        tempBatchRunWorkspace.getFrapStudies().remove(i);
                        tempBatchRunWorkspace.getFrapStudies().add(i, newFRAPStudy);
                    }
                }
                // save loaded tempBatchRunWorkspace to hashtable
                hashTable.put(BATCH_RUN_WORKSPACE_KEY, tempBatchRunWorkspace);
            }
        }
    };
    return openSingleFilesTask;
}
Also used : LocalWorkspace(cbit.vcell.microscopy.LocalWorkspace) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) Hashtable(java.util.Hashtable) FRAPOptFunctions(cbit.vcell.microscopy.FRAPOptFunctions) FRAPModel(cbit.vcell.microscopy.FRAPModel) MicroscopyXmlReader(cbit.vcell.microscopy.MicroscopyXmlReader) FRAPStudy(cbit.vcell.microscopy.FRAPStudy) FRAPOptData(cbit.vcell.microscopy.FRAPOptData) File(java.io.File)

Example 2 with LocalWorkspace

use of cbit.vcell.microscopy.LocalWorkspace in project vcell by virtualcell.

the class VirtualFrapLoader method loadVFRAP.

// the function is called when activate in VCell or as standalone.
public static void loadVFRAP(final String[] args, final boolean bStandalone, final DocumentWindowManager documentWindowManager) {
    try {
        File wd = null;
        if (args == null || args.length == 0) {
            wd = ResourceUtil.getUserHomeDir();
        } else {
            wd = new File(args[0]);
        }
        final File workingDirectory = wd;
        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                LocalWorkspace localWorkspace = new LocalWorkspace(workingDirectory);
                FRAPSingleWorkspace frapWorkspace = new FRAPSingleWorkspace();
                FRAPBatchRunWorkspace batchRunWorkspace = new FRAPBatchRunWorkspace();
                // Check swing availability
                String vers = System.getProperty("java.version");
                if (vers.compareTo("1.1.2") < 0) {
                    System.out.println("!!!WARNING: Swing must be run with a 1.1.2 or higher version JVM!!!");
                }
                if (bStandalone) {
                    /* Set Look and Feel */
                    try {
                        UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
                    } catch (Exception e) {
                        throw new RuntimeException(e.getMessage(), e);
                    }
                }
                // set up file choosers
                openVFRAPFileChooser = new LWFileChooser();
                openVFRAPFileChooser.setDialogTitle("Open Virtual FRAP document (.vfrap)");
                openVFRAPFileChooser.setCurrentDirectory(new File(localWorkspace.getDefaultWorkspaceDirectory()));
                openVFRAPFileChooser.addChoosableFileFilter(filter_vfrap);
                openVFRAPFileChooser.setAcceptAllFileFilterUsed(false);
                openVFRAPBatchRunChooser = new LWFileChooser();
                openVFRAPBatchRunChooser.setDialogTitle("Open Virtual FRAP batchrun document (.vfbatch)");
                openVFRAPBatchRunChooser.setCurrentDirectory(new File(localWorkspace.getDefaultWorkspaceDirectory()));
                openVFRAPBatchRunChooser.addChoosableFileFilter(filter_vfbatch);
                openVFRAPBatchRunChooser.setAcceptAllFileFilterUsed(false);
                loadFRAPImageFileChooser = new LWFileChooser();
                loadFRAPImageFileChooser.setDialogTitle("Load FRAP image file");
                loadFRAPImageFileChooser.setCurrentDirectory(new File(localWorkspace.getDefaultWorkspaceDirectory()));
                loadFRAPImageFileChooser.addChoosableFileFilter(filter_tif);
                loadFRAPImageFileChooser.addChoosableFileFilter(filter_lsm);
                addDataFileChooser_batchRun = new LWFileChooser();
                addDataFileChooser_batchRun.setDialogTitle("Add a Virtual FRAP docmument or FRAP image file to batchrun");
                addDataFileChooser_batchRun.setCurrentDirectory(new File(localWorkspace.getDefaultWorkspaceDirectory()));
                addDataFileChooser_batchRun.addChoosableFileFilter(filter_vfrap);
                addDataFileChooser_batchRun.addChoosableFileFilter(filter_tif);
                addDataFileChooser_batchRun.addChoosableFileFilter(filter_lsm);
                saveFileChooser = new LWFileChooser();
                saveFileChooser.setDialogTitle("Save Virtual FRAP document (.vfrap)");
                saveFileChooser.addChoosableFileFilter(filter_vfrap);
                saveFileChooser.setCurrentDirectory(new File(localWorkspace.getDefaultWorkspaceDirectory()));
                saveAsMatFileChooser = new LWFileChooser();
                saveAsMatFileChooser.setDialogTitle("Save image data to matlab file (.mat)");
                saveAsMatFileChooser.addChoosableFileFilter(filter_mat);
                saveAsMatFileChooser.setCurrentDirectory(new File(localWorkspace.getDefaultWorkspaceDirectory()));
                saveFileChooser_batchRun = new LWFileChooser();
                saveFileChooser_batchRun.setDialogTitle("Save Virtual FRAP batchrun document (.vfbatch)");
                saveFileChooser_batchRun.addChoosableFileFilter(filter_vfbatch);
                saveFileChooser_batchRun.setCurrentDirectory(new File(localWorkspace.getDefaultWorkspaceDirectory()));
                saveFileChooser_batchRunSaveSingleFileAs = new LWFileChooser();
                saveFileChooser_batchRunSaveSingleFileAs.addChoosableFileFilter(filter_vfrap);
                saveFileChooser_batchRunSaveSingleFileAs.setCurrentDirectory(new File(localWorkspace.getDefaultWorkspaceDirectory()));
                multiOpenFileChooser = new LWFileChooser();
                multiOpenFileChooser.setDialogTitle("Open FRAP image series");
                multiOpenFileChooser.setCurrentDirectory(new File(localWorkspace.getDefaultWorkspaceDirectory()));
                multiOpenFileChooser.addChoosableFileFilter(filter_tif);
                multiOpenFileChooser.setMultiSelectionEnabled(true);
                saveMovieFileChooser = new LWFileChooser();
                saveMovieFileChooser.setDialogTitle("Save to quick time movie (.mov)");
                saveMovieFileChooser.addChoosableFileFilter(filter_qt);
                saveMovieFileChooser.setAcceptAllFileFilterUsed(false);
                saveMovieFileChooser.setCurrentDirectory(new File(localWorkspace.getDefaultWorkspaceDirectory()));
                if (mf == null) {
                    mf = new VirtualFrapMainFrame(localWorkspace, frapWorkspace, batchRunWorkspace, bStandalone, documentWindowManager);
                }
                // System.out.println(mf.getLocation().x + "---"+mf.getLocation().y);
                mf.setMainFrameTitle("");
                mf.setVisible(true);
                // initialize FRAPStudy
                FRAPStudy fStudy = new FRAPStudy();
                frapWorkspace.setFrapStudy(fStudy, true);
                try {
                    Thread.sleep(30);
                } catch (InterruptedException e) {
                }
            }
        });
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
}
Also used : LocalWorkspace(cbit.vcell.microscopy.LocalWorkspace) LWFileChooser(org.vcell.client.logicalwindow.LWFileChooser) FRAPStudy(cbit.vcell.microscopy.FRAPStudy) FRAPSingleWorkspace(cbit.vcell.microscopy.FRAPSingleWorkspace) File(java.io.File) FRAPBatchRunWorkspace(cbit.vcell.microscopy.batchrun.FRAPBatchRunWorkspace)

Aggregations

FRAPStudy (cbit.vcell.microscopy.FRAPStudy)2 LocalWorkspace (cbit.vcell.microscopy.LocalWorkspace)2 File (java.io.File)2 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)1 FRAPModel (cbit.vcell.microscopy.FRAPModel)1 FRAPOptData (cbit.vcell.microscopy.FRAPOptData)1 FRAPOptFunctions (cbit.vcell.microscopy.FRAPOptFunctions)1 FRAPSingleWorkspace (cbit.vcell.microscopy.FRAPSingleWorkspace)1 MicroscopyXmlReader (cbit.vcell.microscopy.MicroscopyXmlReader)1 FRAPBatchRunWorkspace (cbit.vcell.microscopy.batchrun.FRAPBatchRunWorkspace)1 Hashtable (java.util.Hashtable)1 LWFileChooser (org.vcell.client.logicalwindow.LWFileChooser)1