use of cbit.vcell.field.io.FieldDataFileOperationSpec in project vcell by virtualcell.
the class RunRefSimulationFastOp method saveROIsAsExternalData.
private void saveROIsAsExternalData(ROI[] rois, LocalWorkspace localWorkspace, ExternalDataIdentifier newROIExtDataID) throws ObjectNotFoundException, ImageException, IOException {
ISize isize = rois[0].getISize();
Origin origin = rois[0].getRoiImages()[0].getOrigin();
Extent extent = rois[0].getRoiImages()[0].getExtent();
VCImage vcImage = new VCImageUncompressed(null, new byte[isize.getXYZ()], extent, isize.getX(), isize.getY(), isize.getZ());
RegionImage regionImage = new RegionImage(vcImage, 0, null, null, RegionImage.NO_SMOOTHING);
CartesianMesh cartesianMesh = CartesianMesh.createSimpleCartesianMesh(origin, extent, isize, regionImage);
int NumTimePoints = 1;
int NumChannels = rois.length;
// dimensions: time points, channels, whole image ordered by z slices.
double[][][] pixData = new double[NumTimePoints][NumChannels][];
int index = 0;
for (ROI roi : rois) {
pixData[0][index++] = createDoubleArray(roi.getBinaryPixelsXYZ(1));
}
// Origin origin = new Origin(0,0,0);
FieldDataFileOperationSpec fdos = new FieldDataFileOperationSpec();
fdos.opType = FieldDataFileOperationSpec.FDOS_ADD;
fdos.cartesianMesh = cartesianMesh;
fdos.doubleSpecData = pixData;
fdos.specEDI = newROIExtDataID;
ArrayList<String> varNames = new ArrayList<String>();
ArrayList<VariableType> varTypes = new ArrayList<VariableType>();
for (ROI roi : rois) {
varNames.add(ROI_MASK_NAME_PREFIX + roi.getROIName());
varTypes.add(VariableType.VOLUME);
}
fdos.varNames = varNames.toArray(new String[0]);
fdos.owner = LocalWorkspace.getDefaultOwner();
fdos.times = new double[] { 0.0 };
fdos.variableTypes = varTypes.toArray(new VariableType[0]);
fdos.origin = origin;
fdos.extent = extent;
fdos.isize = isize;
localWorkspace.getDataSetControllerImpl().fieldDataFileOperation(fdos);
}
use of cbit.vcell.field.io.FieldDataFileOperationSpec in project vcell by virtualcell.
the class RunRefSimulationFastOp method savePsfAsExternalData.
private void savePsfAsExternalData(UShortImage psf, String varName, ExternalDataIdentifier newPsfExtDataID, LocalWorkspace localWorkspace) throws IOException, ImageException, ObjectNotFoundException {
Origin origin = new Origin(0, 0, 0);
Extent ext = new Extent(1, 1, 1);
ISize isize = new ISize(3, 3, 1);
VCImageUncompressed vcImage = new VCImageUncompressed(null, new byte[isize.getXYZ()], ext, isize.getX(), isize.getY(), isize.getZ());
RegionImage regionImage = new RegionImage(vcImage, 0, null, null, RegionImage.NO_SMOOTHING);
CartesianMesh cartesianMesh = CartesianMesh.createSimpleCartesianMesh(origin, ext, isize, regionImage);
int NumTimePoints = 1;
// 8 rois integrated into 1 image
int NumChannels = 1;
short[][][] pixData = new short[NumTimePoints][NumChannels][1];
pixData[0][0] = psf.getPixels();
FieldDataFileOperationSpec fdos = new FieldDataFileOperationSpec();
fdos.opType = FieldDataFileOperationSpec.FDOS_ADD;
fdos.cartesianMesh = cartesianMesh;
fdos.shortSpecData = pixData;
fdos.specEDI = newPsfExtDataID;
fdos.varNames = new String[] { varName };
fdos.owner = LocalWorkspace.getDefaultOwner();
fdos.times = new double[] { 0.0 };
fdos.variableTypes = new VariableType[] { VariableType.VOLUME };
fdos.origin = origin;
fdos.extent = ext;
fdos.isize = isize;
localWorkspace.getDataSetControllerImpl().fieldDataFileOperation(fdos);
}
use of cbit.vcell.field.io.FieldDataFileOperationSpec in project vcell by virtualcell.
the class RunRefSimulationFastOp method saveExternalData.
private void saveExternalData(Image image, String varName, ExternalDataIdentifier newROIExtDataID, LocalWorkspace localWorkspace) throws ObjectNotFoundException, ImageException, IOException {
Extent extent = image.getExtent();
Origin origin = image.getOrigin();
ISize isize = image.getISize();
VCImage vcImage = new VCImageUncompressed(null, new byte[isize.getXYZ()], extent, isize.getX(), isize.getY(), isize.getZ());
RegionImage regionImage = new RegionImage(vcImage, 0, null, null, RegionImage.NO_SMOOTHING);
CartesianMesh simpleCartesianMesh = CartesianMesh.createSimpleCartesianMesh(origin, extent, isize, regionImage);
int NumTimePoints = 1;
int NumChannels = 1;
// dimensions: time points, channels, whole image ordered by z slices.
double[][][] pixData = new double[NumTimePoints][NumChannels][];
pixData[0][0] = image.getDoublePixels();
FieldDataFileOperationSpec fdos = new FieldDataFileOperationSpec();
fdos.opType = FieldDataFileOperationSpec.FDOS_ADD;
fdos.cartesianMesh = simpleCartesianMesh;
fdos.doubleSpecData = pixData;
fdos.specEDI = newROIExtDataID;
fdos.varNames = new String[] { varName };
fdos.owner = LocalWorkspace.getDefaultOwner();
fdos.times = new double[] { 0.0 };
fdos.variableTypes = new VariableType[] { VariableType.VOLUME };
fdos.origin = origin;
fdos.extent = extent;
fdos.isize = isize;
localWorkspace.getDataSetControllerImpl().fieldDataFileOperation(fdos);
}
use of cbit.vcell.field.io.FieldDataFileOperationSpec in project vcell by virtualcell.
the class ClientRequestManager method createFDOSFromSurfaceFile.
public static FieldDataFileOperationSpec createFDOSFromSurfaceFile(File surfaceFile) throws Exception {
SurfaceCollection surfaceCollection = createSurfaceCollectionFromSurfaceFile(surfaceFile);
if (surfaceCollection != null) {
Geometry geometry = RayCaster.createGeometryFromSTL(new GeometryThumbnailImageFactoryAWT(), surfaceCollection, 1000000);
FieldDataFileOperationSpec fdfos = new FieldDataFileOperationSpec();
fdfos.origin = geometry.getOrigin();
fdfos.extent = geometry.getExtent();
VCImage image = geometry.getGeometrySpec().getImage();
if (image.getNumPixelClasses() == 1) {
throw new Exception("STL import failed during processing, pixelclass count=1");
}
fdfos.isize = new ISize(image.getNumX(), image.getNumY(), image.getNumZ());
byte[] pixels = image.getPixels();
short[] dataToSegment = new short[image.getNumXYZ()];
for (int i = 0; i < pixels.length; i++) {
dataToSegment[i] = pixels[i];
}
fdfos.shortSpecData = new short[][][] { { dataToSegment } };
return fdfos;
}
return null;
}
use of cbit.vcell.field.io.FieldDataFileOperationSpec in project vcell by virtualcell.
the class ClientRequestManager method getResizeImageTask.
public static AsynchClientTask getResizeImageTask(final VCDocument.DocumentCreationInfo documentCreationInfo) {
AsynchClientTask resizeImageTask = new AsynchClientTask("Resizing Image...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
ImageSizeInfo newImageSizeInfo = (ImageSizeInfo) hashTable.get(NEW_IMAGE_SIZE_INFO);
FieldDataFileOperationSpec fdfos = (FieldDataFileOperationSpec) hashTable.get(FDFOS);
if (newImageSizeInfo != null && fdfos != null && !fdfos.isize.compareEqual(newImageSizeInfo.getiSize())) {
// resizeImage((FieldDataFileOperationSpec) hashTable.get(FDFOS), newImageSizeInfo.getiSize(),
// documentCreationInfo.getOption());
resize0(hashTable);
}
}
};
return resizeImageTask;
}
Aggregations