jist:FAQ-QAO-DEV
From NITRC Wiki
FAQ-QAO for Users FAQ-QAO for Developers
Frequently Asked Questions and Questions Asked Once for Developers
| Q: | My JIST modules are using WAY too much memory?!? Help! |
| A: | When JIST modules are developed with input classes of “Volume” or “Surface”, then all of the inputs are loaded prior to computation and all of the outputs are written after computation. No inputs or outputs are closed until the module is finished and the system is sure that the data are no longer needed. This behavior is by design and can lead to efficient computation when all analyses are being run in a single thread. However, for certain memory intensive tasks or tasks that involve many intermediates which should be written out and closed prior to completion, then this behavior is not desirable.
Fortunately, JIST supports a complementary method of data exchange through generic “File” types. The type of data may be validated by setting acceptable file extensions. Image/surface dimensions/resolutions/etc. cannot be validated prior to the start of the module because the data are not opened by the system. However, it is essentially trivial to query the JIST interface to load the data for you, write out data when you are done, and close the image at the end. You can create an input parameter to accept any file with a valid image extension with the following code example:
mainParams.add(sourceVols= new ParamFileCollection("Source Volumes",new FileExtensionFilter(ModelImageReaderWriter.supportedFileExtensions)));
mainParams.add(targetVol= new ParamFile("Target Volume",new FileExtensionFilter(ModelImageReaderWriter.supportedFileExtensions)));
To read a volume, use: CubicVolumeReaderWriter rw = CubicVolumeReaderWriter.getInstance(); ImageData target = rw.read(targetVol.getValue()); To free memory associated with a volume: vol.dispose(); vol=null; To save a volume use: CubicVolumeReaderWriter rw = CubicVolumeReaderWriter.getInstance(); File f2 = rw.write(thisreg, f1); See the “edu.jhu.ece.iacl.plugins.registration.MedicAlgorithmEfficientFileCollectionRegistration” for an example of how this works.
|
| Q: | I can import multiple input files to a single node and read them, but I don't know how to export multiple files from the same node. How can I do this? |
| A: | Use the ParamFileCollection output type rather than the ParamFile output type. The creation syntax is similar for both types (for CreateOutputParamters). However, rather than using .setValue(…) with a File object, use .setValue(…) with a List<File> object. The class edu.jhu.ece.iacl.plugins.registration. MedicAlgorithmEfficientFileCollectionRegistration has examples of using ParamFileCollection for both input and output parameters. A word of caution: Be sure to write your results into a reasonable path (either your experiment directory or a subdirectory of the experiment). When you use the ParamFile* types for output, you take on the responsibility for locating your files and naming them. See the .getOutputDirectory() in ProcessingAlgorithm to get the current output directory (i.e., the base directory for the current experiment). |
| Q: | Question |
| A: | Answer |








