Commit 6e63f8c6 authored by Muyuan Chen's avatar Muyuan Chen
Browse files

Merge branch 'master' of github.com:cryoem/eman2

parents 8c168721 b965fcf6
......@@ -1458,7 +1458,7 @@ int HdfIO2::write_header(const Dict & dict, int image_index, const Region* area,
}
template<EMUtil::EMDataType I>
auto HdfIO2::write(float *data, size_t size, hid_t ds, hid_t memoryspace, hid_t filespace) {
auto HdfIO2::write_compressed(float *data, size_t size, hid_t ds, hid_t memoryspace, hid_t filespace) {
auto [rendered_data, rendertrunc] = getRenderedDataAndRendertrunc<typename EM2Type<I>::type>(data, size);
auto err_no = H5Dwrite(ds, EM2HDF[I], memoryspace, filespace, H5P_DEFAULT, rendered_data.data());
......@@ -1469,12 +1469,6 @@ auto HdfIO2::write(float *data, size_t size, hid_t ds, hid_t memoryspace, hid_t
return std::make_tuple(I != EMUtil::EM_FLOAT, rendertrunc);
}
auto HdfIO2::write_compressed(float *data, hsize_t size, hid_t ds, hid_t spc1, hid_t spc2) {
if (renderbits<=0) return write<EMUtil::EM_FLOAT>(data, size, ds, spc1, spc2);
else if (renderbits<=8) return write<EMUtil::EM_UCHAR>(data, size, ds, spc1, spc2);
else return write<EMUtil::EM_USHORT>(data, size, ds, spc1, spc2);
}
// Writes the actual image data to the corresponding dataset (already created)
int HdfIO2::write_data(float *data, int image_index, const Region* area,
EMUtil::EMDataType dt, bool)
......@@ -1498,7 +1492,6 @@ int HdfIO2::write_data(float *data, int image_index, const Region* area,
sprintf(ipath, "/MDF/images/%d/image", image_index);
// Now create the image dataspace (not used for region writing)
hsize_t rank = 0;
if (nz == 1 && ny == 1) {
hsize_t dims[1]= { nx };
spc=H5Screate_simple(1,dims,NULL);
......@@ -1575,6 +1568,7 @@ int HdfIO2::write_data(float *data, int image_index, const Region* area,
}
hsize_t rank = 0;
if (ds < 0) { //new dataset
hid_t plist = H5Pcreate(H5P_DATASET_CREATE); // we could just use H5P_DEFAULT for non-compressed
if (dt==EMUtil::EM_COMPRESSED) {
......@@ -1616,9 +1610,6 @@ int HdfIO2::write_data(float *data, int image_index, const Region* area,
// convert data to unsigned short, unsigned char...
hsize_t size = (hsize_t)nx*ny*nz;
EMUtil::getRenderMinMax(data, nx, ny, rendermin, rendermax, renderbits, nz);
// printf("RMM %f %f\n",rendermin,rendermax);
hid_t filespace = 0;
hid_t memoryspace = 0;
......@@ -1680,27 +1671,26 @@ int HdfIO2::write_data(float *data, int image_index, const Region* area,
}
}
hid_t spc1 = (area ? memoryspace : spc);
hid_t spc2 = (area ? filespace : spc);
hid_t spc1 = 0;
hid_t spc2 = 0;
if (area) {
spc1 = memoryspace;
spc2 = filespace;
}
else {
spc1 = spc;
spc2 = spc;
EMUtil::getRenderMinMax(data, nx, ny, rendermin, rendermax, renderbits, nz);
// printf("RMM %f %f\n",rendermin,rendermax);
if(dt == EMUtil::EM_COMPRESSED) {
if (renderbits <= 0) dt = EMUtil::EM_FLOAT;
else if (renderbits <= 8) dt = EMUtil::EM_UCHAR;
else dt = EMUtil::EM_USHORT;
}
int rendertrunc = 0; // keep track of truncated pixels
bool scaled = 0; // set if the data will need rescaling upon read
switch(dt) {
case EMUtil::EM_FLOAT: std::tie(scaled, rendertrunc) = write<EMUtil::EM_FLOAT>(data, size, ds, spc1, spc2); break;
case EMUtil::EM_SHORT: std::tie(scaled, rendertrunc) = write<EMUtil::EM_SHORT>(data, size, ds, spc1, spc2); break;
case EMUtil::EM_USHORT: std::tie(scaled, rendertrunc) = write<EMUtil::EM_USHORT>(data, size, ds, spc1, spc2); break;
case EMUtil::EM_CHAR: std::tie(scaled, rendertrunc) = write<EMUtil::EM_CHAR>(data, size, ds, spc1, spc2); break;
case EMUtil::EM_UCHAR: std::tie(scaled, rendertrunc) = write<EMUtil::EM_UCHAR>(data, size, ds, spc1, spc2); break;
case EMUtil::EM_COMPRESSED: std::tie(scaled, rendertrunc) = write_compressed(data, size, ds, spc1, spc2); break;
case EMUtil::EM_FLOAT: std::tie(scaled, rendertrunc) = write_compressed<EMUtil::EM_FLOAT>(data, size, ds, spc1, spc2); break;
case EMUtil::EM_SHORT: std::tie(scaled, rendertrunc) = write_compressed<EMUtil::EM_SHORT>(data, size, ds, spc1, spc2); break;
case EMUtil::EM_USHORT: std::tie(scaled, rendertrunc) = write_compressed<EMUtil::EM_USHORT>(data, size, ds, spc1, spc2); break;
case EMUtil::EM_CHAR: std::tie(scaled, rendertrunc) = write_compressed<EMUtil::EM_CHAR>(data, size, ds, spc1, spc2); break;
case EMUtil::EM_UCHAR: std::tie(scaled, rendertrunc) = write_compressed<EMUtil::EM_UCHAR>(data, size, ds, spc1, spc2); break;
default:
throw ImageWriteException(filename,"HDF5 does not support this data format");
}
......
......@@ -129,8 +129,7 @@ namespace EMAN
private:
template<EMUtil::EMDataType I>
auto write(float *data, size_t size, hid_t ds, hid_t memoryspace, hid_t filespace);
auto write_compressed(float *data, hsize_t size, hid_t ds, hid_t spc1, hid_t spc2);
auto write_compressed(float *data, size_t size, hid_t ds, hid_t memoryspace, hid_t filespace);
private:
hsize_t nx, ny, nz;
......
......@@ -497,7 +497,7 @@ class EMAnnotate2DWidget(EMGLWidget):
def register_scroll_motion(self,x,y,z=0):
if self.list_data!=None:
self.image_range_changed(z)
self.ns_changed(z)
#self.setup_shapes()
animation = LineAnimation(self,self.origin,(x*self.scale-old_div(self.width(),2),y*self.scale-old_div(self.height(),2)))
self.qt_parent.register_animatable(animation)
......@@ -1013,7 +1013,6 @@ class EMAnnotate2DWidget(EMGLWidget):
def inspector_update(self):
if not self.inspector is None and not self.data is None:
self.inspector.set_limits(self.minden,self.maxden,self.curmin,self.curmax)
self.inspector.set_gamma(self.gamma)
self.inspector.set_scale(self.scale)
self.inspector.update_brightness_contrast()
......@@ -1864,7 +1863,7 @@ class EMAnnotateInspector2D(QtWidgets.QWidget):
def update_zrange(self):
nz=self.target().get_data()["nz"]
zr=nz*3//4 # approximate max z range with high tilt
self.image_range.setRange(-zr,zr)
self.ns.setRange(-zr,zr)
self.stminsb.setRange(-zr,zr)
self.stminsb.setValue(-nz)
self.stmaxsb.setRange(-zr,zr)
......@@ -2068,7 +2067,7 @@ class EMAnnotateInspector2D(QtWidgets.QWidget):
self.pyout.setText(str(r))
def set_image_idx(self,val,quiet=0):
self.image_range.setValue(val,quiet=quiet)
self.ns.setValue(val,quiet=quiet)
def get_contrast(self):
return float(self.conts.getValue())
......@@ -2088,9 +2087,6 @@ class EMAnnotateInspector2D(QtWidgets.QWidget):
def set_minden(self,value,quiet=1):
self.mins.setValue(value,quiet)
def set_gamma(self,value,quiet=1):
self.gammas.setValue(value,quiet)
def set_scale(self,val):
if self.busy : return
self.busy=1
......@@ -2123,11 +2119,6 @@ class EMAnnotateInspector2D(QtWidgets.QWidget):
self.update_min_max()
self.busy=0
def new_gamma(self,val):
if self.busy : return
self.busy=1
self.target().set_gamma(val)
self.busy=0
def update_brightness_contrast(self):
b=0.5*(self.mins.value+self.maxs.value-(self.lowlim+self.highlim))/((self.highlim-self.lowlim))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment