 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
26 cout <<
"DEBUG view_from_imagic_euler: " << view << endl;
33 if ( acos(view[2]) > 1e-14 )
34 header->
reg[
PHI_BP].
f = atan2(view[1], view[0]);
62 ifstream* fimg =
new ifstream(p->
file_name());
63 if ( fimg->fail() )
return -1;
68 error_show(
"Suprim version number incorrect", __FILE__, __LINE__);
76 error_show(
"Suprim header not read", __FILE__, __LINE__);
81 unsigned char* b = (
unsigned char *) header;
85 cerr <<
"Warning: Swapping header byte order for 4-byte types" << endl;
88 for ( i=0; i<extent; i+=4 )
swapbytes(b+i, 4);
101 cout <<
"DEBUG readSUPRIM: version byte = " <<
version << endl;
102 cout <<
"DEBUG readSUPRIM: data size = " << header->ncol <<
"," << header->nrow <<
"," << header->reg[
NSLICES].l << endl;
106 unsigned char* ptr = (
unsigned char *) header->trace;
107 int* iptr = (
int *) ptr;
109 fimg->read((
char *)ptr, 4);
111 int it =
sizeof(int);
112 int narg = *iptr + 2;
113 if (
verbose &
VERB_DEBUG ) cout <<
"DEBUG readSUPRIM: number of trace arguments = " << narg << endl;
115 cerr <<
"Error: The number of trace arguments are too large! (" << narg <<
")" << endl;
116 cerr <<
" First trace bytes: " << ptr[0] <<
" " << ptr[1] <<
" " << ptr[2] <<
" " << ptr[3] << endl;
119 for ( i=0; i<narg; i++) {
121 fimg->read((
char *)&ptr[it], 4);
123 iptr = (
int *) &ptr[it];
126 fimg->read((
char *)&ptr[it], *iptr);
128 cout <<
"DEBUG readSUPRIM: trace " << i+1 <<
" (" << *iptr <<
"): " << &ptr[it] << endl;
129 if ( i == 2 ) p->
label((
char *) &ptr[it]);
131 cout <<
"DEBUG readSUPRIM: label: " << p->
label() << endl;
138 cout <<
"DEBUG readSUPRIM: data offset = " << p->
data_offset() << endl;
141 p->
size(header->ncol, header->nrow, header->reg[
NSLICES].l);
146 switch ( header->intern ) {
164 cout <<
"DEBUG readSUPRIM: data type = " << p->
data_type() << endl;
171 cout <<
"DEBUG readSUPRIM: background = " << p->
background(
long(0)) << endl;
178 cout <<
"DEBUG readSUPRIM: Header setup done" << endl;
192 cout <<
"DEBUG readSUPRIM: Data read" << endl;
238 default: header->
intern = 1;
break;
253 char* ptr = (
char *) header->
trace;
254 int* iptr = (
int *) ptr;
257 memcpy(ptr + 8,
"Bsoft1.4", 8);
258 iptr = (
int *) (ptr + 20);
261 iptr = (
int *) (ptr + 48);
265 long llen = p->
label().length();
266 if ( llen > 800 ) llen = 800;
268 memcpy(ptr + 52, p->
label().c_str(), llen);
272 header->
format = datatypesize;
276 cout <<
"DEBUG writeSUPRIM: version byte=" <<
version << endl;
277 cout <<
"DEBUG writeSUPRIM: size:" << header->
ncol <<
"," << header->
nrow <<
"," << header->
reg[
NSLICES].
l << endl;
278 cout <<
"DEBUG writeSUPRIM: offset=" << p->
data_offset() <<
" data size=" << datasize << endl;
279 cout <<
"DEBUG writeSUPRIM: number of trace arguments = " << iptr[0] << endl;
280 cout <<
"DEBUG writeSUPRIM: trace = ";
281 for (
int i=0; i<20; i++ ) cout << i <<
" " << header->
trace[i] <<
" " << header->
trace[i] << endl;
286 if ( fimg.fail() )
return -1;
int writeSUPRIM(Bimage *p)
Writing a SUPRIM map image file format. A 3D image format used in electron microscopy.
Header file for file checking functions.
int fread_large(unsigned char *aptr, size_t pagesize, size_t offset, ifstream *fimg)
Reads blocks of memeory no larger than 1Gb.
View view_from_suprim_euler(SUPRIMhead *header)
int error_show(string message, string file, int line)
Displays the error with file and line reference.
double background(long nn)
Vector3< long > size() const
long data_type_size() const
Returns the size of the datatype in bytes.
void view(double x, double y, double z, double a)
double standard_deviation()
double angle_set_negPI_to_PI(double angle)
Returns an angle between -PI and PI.
void origin(double x, double y, double z)
void swapbytes(unsigned char *v, size_t n)
Swaps bytes.
FourierType fourier_type()
Header file for reading and writing SUPRIM files.
General image parameter class.
CompoundType compound_type()
double average(long cc, double xf, double yf, double zf, long nn, double iscale)
Averages in 3D when scaling is less than 1.
unsigned char * data_alloc()
int suprim_euler_from_view(SUPRIMhead *header, View view)
Header file for general utilities.
void origin(double ox, double oy, double oz)
void change_type(char letter)
Get the data type indicated by a single letter code.
unsigned char * data_pointer()
void sampling(long nn, Vector3< double > u)
int readSUPRIM(Bimage *p, int readdata)
Reading a SUPRIM map image file format. A 3D image format used in electron microscopy....