EMAN2
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
wustl_mm::SkeletonMaker::VolumeData Class Reference

#include <volume_data.h>

Collaboration diagram for wustl_mm::SkeletonMaker::VolumeData:
Collaboration graph
[legend]

Public Member Functions

 VolumeData (EMData *em)
 
 VolumeData (int sizeX, int sizeY, int sizeZ)
 
 VolumeData (int sizeX, int sizeY, int sizeZ, float val)
 
 VolumeData (int sizeX, int sizeY, int sizeZ, int offsetX, int offsetY, int offsetZ, VolumeData *data)
 
 VolumeData (VolumeData &obj)
 
 ~VolumeData ()
 
int GetSize (int dimension)
 
int GetSizeX ()
 
int GetSizeY ()
 
int GetSizeZ ()
 
float GetSpacing (int dimension)
 
float GetSpacingX ()
 
float GetSpacingY ()
 
float GetSpacingZ ()
 
float GetOrigin (int dimension)
 
float GetOriginX ()
 
float GetOriginY ()
 
float GetOriginZ ()
 
float GetDataAt (int x, int y, int z)
 
float GetDataAt (int index)
 
int GetIndex (int x, int y, int z)
 
int GetMaxIndex ()
 
void SetSpacing (float spacingX, float spacingY, float spacingZ)
 
void SetOrigin (float originX, float originY, float originZ)
 
void SetDataAt (int x, int y, int z, float value)
 
void SetDataAt (int index, float value)
 
void Pad (int padBy, double padValue)
 
EMDataget_emdata ()
 

Public Attributes

bool owns_emdata
 

Private Member Functions

void InitializeVolumeData (int sizeX, int sizeY, int sizeZ, float spacingX, float spacingY, float spacingZ, float originX, float originY, float originZ, bool initializeData, float val)
 
void SetSize (int sizeX, int sizeY, int sizeZ)
 

Private Attributes

EMDataemdata
 

Detailed Description

Definition at line 12 of file volume_data.h.

Constructor & Destructor Documentation

◆ VolumeData() [1/5]

VolumeData::VolumeData ( EMData em)

Definition at line 9 of file volume_data.cpp.

10 {
11 this->emdata = em;
12 owns_emdata = false;
13 }

References emdata, and owns_emdata.

◆ VolumeData() [2/5]

VolumeData::VolumeData ( int  sizeX,
int  sizeY,
int  sizeZ 
)

Definition at line 15 of file volume_data.cpp.

15 {
16 InitializeVolumeData(sizeX, sizeY, sizeZ, 1, 1, 1, 0, 0, 0, true, 0);
17 }
void InitializeVolumeData(int sizeX, int sizeY, int sizeZ, float spacingX, float spacingY, float spacingZ, float originX, float originY, float originZ, bool initializeData, float val)
Definition: volume_data.cpp:49

References InitializeVolumeData().

◆ VolumeData() [3/5]

VolumeData::VolumeData ( int  sizeX,
int  sizeY,
int  sizeZ,
float  val 
)

Definition at line 19 of file volume_data.cpp.

19 {
20 InitializeVolumeData(sizeX, sizeY, sizeZ, 1, 1, 1, 0, 0, 0, true, val);
21 }

References InitializeVolumeData().

◆ VolumeData() [4/5]

VolumeData::VolumeData ( int  sizeX,
int  sizeY,
int  sizeZ,
int  offsetX,
int  offsetY,
int  offsetZ,
VolumeData data 
)

Definition at line 23 of file volume_data.cpp.

23 {
24 InitializeVolumeData(sizeX, sizeY, sizeZ, data->GetSpacingX(), data->GetSpacingY(), data->GetSpacingZ(), data->GetOriginX(), data->GetOriginY(), data->GetOriginZ(), false, 0);
25 float value;
26 for ( int k = offsetZ; k < sizeZ + offsetZ; k++) {
27 for (int j = offsetY; j < sizeY + offsetY; j++ ) {
28 for (int i = offsetX; i < sizeX + offsetX; i++) {
29 value = data->GetDataAt(i,j,k);
30 SetDataAt(i-offsetX,j-offsetY,k-offsetZ, value);
31 }
32 }
33 }
34 }
void SetDataAt(int x, int y, int z, float value)
float GetDataAt(int x, int y, int z)

References GetDataAt(), GetOriginX(), GetOriginY(), GetOriginZ(), GetSpacingX(), GetSpacingY(), GetSpacingZ(), InitializeVolumeData(), and SetDataAt().

◆ VolumeData() [5/5]

VolumeData::VolumeData ( VolumeData obj)

Definition at line 36 of file volume_data.cpp.

37 {
38 emdata = new EMData( *obj.get_emdata() );
39 owns_emdata = true;
40 //SetSize( obj.GetSizeX(), obj.GetSizeY(), obj.GetSizeZ() );
41 //SetSpacing( obj.GetSpacingX(), obj.GetSpacingY(), obj.GetSpacingZ() );
42 //SetOrigin( obj.GetOriginX(), GetOriginY(), obj.GetOriginZ() );
43 }
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82

References emdata, get_emdata(), and owns_emdata.

◆ ~VolumeData()

VolumeData::~VolumeData ( )

Definition at line 44 of file volume_data.cpp.

44 {
45 if (owns_emdata)
46 delete emdata;
47 }

References emdata, and owns_emdata.

Member Function Documentation

◆ get_emdata()

EMData * VolumeData::get_emdata ( )

Definition at line 166 of file volume_data.cpp.

167 {
168 return emdata;
169 }

References emdata.

Referenced by wustl_mm::SkeletonMaker::Volume::get_emdata(), and VolumeData().

◆ GetDataAt() [1/2]

float VolumeData::GetDataAt ( int  index)

Definition at line 153 of file volume_data.cpp.

153 {
154 //TODO: This may be a problem because EMAN2 and Gorgon do indexing differently --> see if this causes problems
155 return emdata->get_value_at(index);
156 }

References emdata.

◆ GetDataAt() [2/2]

float VolumeData::GetDataAt ( int  x,
int  y,
int  z 
)

Definition at line 149 of file volume_data.cpp.

149 {
150 return this->emdata->get_value_at(x, y, z);
151 }
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

References emdata, and y.

Referenced by wustl_mm::SkeletonMaker::Volume::getDataAt(), Pad(), and VolumeData().

◆ GetIndex()

int VolumeData::GetIndex ( int  x,
int  y,
int  z 
)

Definition at line 158 of file volume_data.cpp.

158 {
159 return (x + y * GetSizeX() + z * GetSizeX() * GetSizeY());
160 }

References GetSizeX(), GetSizeY(), x, and y.

Referenced by wustl_mm::SkeletonMaker::Volume::getIndex().

◆ GetMaxIndex()

int VolumeData::GetMaxIndex ( )

Definition at line 162 of file volume_data.cpp.

162 {
163 return GetSizeX() * GetSizeY() * GetSizeZ();
164 }

References GetSizeX(), GetSizeY(), and GetSizeZ().

◆ GetOrigin()

float VolumeData::GetOrigin ( int  dimension)

Definition at line 119 of file volume_data.cpp.

119 {
120 float ret = 0;
121 switch (dimension)
122 {
123 case 0: ret = GetOriginX();
124 break;
125 case 1: ret = GetOriginY();
126 break;
127 case 2: ret = GetOriginZ();
128 break;
129 default:
130 throw InvalidParameterException("VolumeData::GetOrigin requires an argument of 0, 1, or 2");
131 }
132
133 return ret;
134 }
#define InvalidParameterException(desc)
Definition: exception.h:361

References GetOriginX(), GetOriginY(), GetOriginZ(), and InvalidParameterException.

◆ GetOriginX()

float VolumeData::GetOriginX ( )

Definition at line 136 of file volume_data.cpp.

136 {
137 return emdata->get_attr("origin_x");
138 }

References emdata.

Referenced by GetOrigin(), wustl_mm::SkeletonMaker::Volume::getOriginX(), and VolumeData().

◆ GetOriginY()

float VolumeData::GetOriginY ( )

Definition at line 140 of file volume_data.cpp.

140 {
141 return emdata->get_attr("origin_y");
142 }

References emdata.

Referenced by GetOrigin(), wustl_mm::SkeletonMaker::Volume::getOriginY(), and VolumeData().

◆ GetOriginZ()

float VolumeData::GetOriginZ ( )

Definition at line 144 of file volume_data.cpp.

144 {
145 return emdata->get_attr("origin_z");
146 }

References emdata.

Referenced by GetOrigin(), wustl_mm::SkeletonMaker::Volume::getOriginZ(), and VolumeData().

◆ GetSize()

int VolumeData::GetSize ( int  dimension)

Definition at line 60 of file volume_data.cpp.

60 {
61 int ret = 0;
62 switch (dimension)
63 {
64 case 0: ret = GetSizeX();
65 break;
66 case 1: ret = GetSizeY();
67 break;
68 case 2: ret = GetSizeZ();
69 break;
70 default:
71 throw InvalidParameterException("VolumeData::GetSize requires an argument of 0, 1, or 2");
72 }
73
74 return ret;
75
76 }

References GetSizeX(), GetSizeY(), GetSizeZ(), and InvalidParameterException.

◆ GetSizeX()

int VolumeData::GetSizeX ( )

Definition at line 78 of file volume_data.cpp.

78 {
79 return emdata->get_xsize();
80 }

References emdata.

Referenced by GetIndex(), GetMaxIndex(), GetSize(), wustl_mm::SkeletonMaker::Volume::getSizeX(), and Pad().

◆ GetSizeY()

int VolumeData::GetSizeY ( )

Definition at line 82 of file volume_data.cpp.

82 {
83 return emdata->get_ysize();
84 }

References emdata.

Referenced by GetIndex(), GetMaxIndex(), GetSize(), wustl_mm::SkeletonMaker::Volume::getSizeY(), and Pad().

◆ GetSizeZ()

int VolumeData::GetSizeZ ( )

Definition at line 86 of file volume_data.cpp.

86 {
87 return emdata->get_zsize();
88 }

References emdata.

Referenced by GetMaxIndex(), GetSize(), wustl_mm::SkeletonMaker::Volume::getSizeZ(), and Pad().

◆ GetSpacing()

float VolumeData::GetSpacing ( int  dimension)

Definition at line 90 of file volume_data.cpp.

90 {
91 float ret = 0;
92 switch (dimension)
93 {
94 case 0: ret = GetSpacingX();
95 break;
96 case 1: ret = GetSpacingY();
97 break;
98 case 2: ret = GetSpacingZ();
99 break;
100 default:
101 throw InvalidParameterException("VolumeData::GetSpacing requires an argument of 0, 1, or 2");
102 }
103
104 return ret;
105 }

References GetSpacingX(), GetSpacingY(), GetSpacingZ(), and InvalidParameterException.

◆ GetSpacingX()

float VolumeData::GetSpacingX ( )

Definition at line 107 of file volume_data.cpp.

107 {
108 return emdata->get_attr("apix_x");
109 }

References emdata.

Referenced by GetSpacing(), wustl_mm::SkeletonMaker::Volume::getSpacingX(), and VolumeData().

◆ GetSpacingY()

float VolumeData::GetSpacingY ( )

Definition at line 111 of file volume_data.cpp.

111 {
112 return emdata->get_attr("apix_y");
113 }

References emdata.

Referenced by GetSpacing(), wustl_mm::SkeletonMaker::Volume::getSpacingY(), and VolumeData().

◆ GetSpacingZ()

float VolumeData::GetSpacingZ ( )

Definition at line 115 of file volume_data.cpp.

115 {
116 return emdata->get_attr("apix_y");
117 }

References emdata.

Referenced by GetSpacing(), wustl_mm::SkeletonMaker::Volume::getSpacingZ(), and VolumeData().

◆ InitializeVolumeData()

void VolumeData::InitializeVolumeData ( int  sizeX,
int  sizeY,
int  sizeZ,
float  spacingX,
float  spacingY,
float  spacingZ,
float  originX,
float  originY,
float  originZ,
bool  initializeData,
float  val 
)
private

Definition at line 49 of file volume_data.cpp.

49 {
50 emdata = new EMData(sizeX, sizeY, sizeZ);
51 owns_emdata = true;
52 //SetSize(sizeX, sizeY, sizeZ);
53 SetSpacing(spacingX, spacingY, spacingZ);
54 SetOrigin(originX, originY, originZ);
55 if(initializeData) {
56 emdata->to_value(val);
57 }
58 }
void SetOrigin(float originX, float originY, float originZ)
void SetSpacing(float spacingX, float spacingY, float spacingZ)

References emdata, owns_emdata, SetOrigin(), and SetSpacing().

Referenced by VolumeData().

◆ Pad()

void VolumeData::Pad ( int  padBy,
double  padValue 
)

Definition at line 196 of file volume_data.cpp.

196 {
197
198 int sizex = GetSizeX();
199 int sizey = GetSizeY();
200 int sizez = GetSizeZ();
201 int newSizeX = sizex + 2*padBy;
202 int newSizeY = sizey + 2*padBy;
203 int newSizeZ = sizez + 2*padBy;
204
205 // Method 1: Using get_clip ===========================================================
206// Region reg(0, 0, 0, newSizeX, newSizeY, newSizeZ);
207// EMData * new_emdata = emdata->get_clip(reg); //Extends the area x > sizex, y > sizey, z > sizez but does not translate (0,0,0)
208// new_emdata->translate(padBy,padBy,padBy); //We want equal padding on each side
209//
210// for(int z = 0; z < newSizeZ; z++)
211// for(int y = 0; y < newSizeY; y++)
212// for(int x = 0; x < newSizeX; x++)
213// if ((x < padBy) || (y < padBy) || (z < padBy) || (x >= padBy + sizex) || (y >= padBy + sizey) || (z >= padBy + sizez))
214// new_emdata->set_value_at(x, y, z, padValue);
215//
216// if (this->owns_emdata)
217// this->emdata->free_memory();
218// this->emdata = new_emdata;
219
220 // Method 2: making a copy =============================================================
221 float * newData = (float*) malloc ( newSizeX * newSizeY * newSizeZ * sizeof(float) );
222 double value;
223
224 for(int z = 0; z < newSizeZ; z++) {
225 for(int y = 0; y < newSizeY; y++) {
226 for(int x = 0; x < newSizeX; x++) {
227 if ((x < padBy) || (y < padBy) || (z < padBy) || (x >= padBy + sizex) || (y >= padBy + sizey) || (z >= padBy + sizez)) {
228 value = padValue;
229 } else {
230 value = GetDataAt(x-padBy, y-padBy, z-padBy);
231 }
232
233 newData[x + y * newSizeX + z * newSizeX * newSizeY] = static_cast<float>(value); //eman2
234 }
235 }
236 }
237
238 SetSize(newSizeX, newSizeY, newSizeZ);
239 emdata->set_data(newData, newSizeX, newSizeY, newSizeZ);
240 //free(data); //I think this is handled by set_data
241
242 // Method 3: doing in-place resize =====================================================
243// emdata->set_size(newSizeX, newSizeY, newSizeZ);
244// double val;
245// for (int k = newSizeZ - 1; k >= 0; k--)
246// for (int j = newSizeY - 1; k >= 0; j--)
247// for (int i = newSizeX - 1; k >=0; k--)
248// {
249// if ( i < padBy || i >= sizex+padBy || j < padBy || j >= sizey+padBy || k < padBy || k >= sizez+padBy)
250// emdata->set_value_at(i,j,k, padValue);
251// else
252// {
253// val = emdata->get_value_at(i-padBy, j-padBy, k-padBy);
254// emdata->set_value_at(i,j,k, float(val));
255// }
256// }
257 }
void SetSize(int sizeX, int sizeY, int sizeZ)

References emdata, GetDataAt(), GetSizeX(), GetSizeY(), GetSizeZ(), SetSize(), x, and y.

Referenced by wustl_mm::SkeletonMaker::Volume::pad().

◆ SetDataAt() [1/2]

void VolumeData::SetDataAt ( int  index,
float  value 
)

Definition at line 192 of file volume_data.cpp.

192 {
193 //TODO: This may be a problem because EMAN2 and Gorgon do indexing differently --> see if this causes problems
194 emdata->get_data()[index] = value;
195 }

References emdata.

◆ SetDataAt() [2/2]

void VolumeData::SetDataAt ( int  x,
int  y,
int  z,
float  value 
)

Definition at line 188 of file volume_data.cpp.

188 {
189 emdata->set_value_at(x, y, z, value);
190 }

References emdata, x, and y.

Referenced by wustl_mm::SkeletonMaker::Volume::setDataAt(), and VolumeData().

◆ SetOrigin()

void VolumeData::SetOrigin ( float  originX,
float  originY,
float  originZ 
)

Definition at line 177 of file volume_data.cpp.

177 {
178 emdata->set_attr("origin_x", originX);
179 emdata->set_attr("origin_y", originY);
180 emdata->set_attr("origin_z", originZ);
181 }

References emdata.

Referenced by InitializeVolumeData(), and wustl_mm::SkeletonMaker::Volume::setOrigin().

◆ SetSize()

void VolumeData::SetSize ( int  sizeX,
int  sizeY,
int  sizeZ 
)
private

Definition at line 184 of file volume_data.cpp.

184 {
185 emdata->set_size(sizeX, sizeY, sizeZ);
186 }

References emdata.

Referenced by Pad().

◆ SetSpacing()

void VolumeData::SetSpacing ( float  spacingX,
float  spacingY,
float  spacingZ 
)

Definition at line 171 of file volume_data.cpp.

171 {
172 emdata->set_attr("apix_x", spacingX);
173 emdata->set_attr("apix_y", spacingY);
174 emdata->set_attr("apix_z", spacingZ);
175 }

References emdata.

Referenced by InitializeVolumeData(), and wustl_mm::SkeletonMaker::Volume::setSpacing().

Member Data Documentation

◆ emdata

EMData* wustl_mm::SkeletonMaker::VolumeData::emdata
private

◆ owns_emdata

bool wustl_mm::SkeletonMaker::VolumeData::owns_emdata

The documentation for this class was generated from the following files: