EMAN2
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
wustl_mm::SkeletonMaker::VolumeData Class Reference

#include <volume_data.h>

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

List of all members.

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::VolumeData ( EMData em)

Definition at line 9 of file volume_data.cpp.

References emdata, and owns_emdata.

                {
                        this->emdata = em;
                        owns_emdata = false;
                }
VolumeData::VolumeData ( int  sizeX,
int  sizeY,
int  sizeZ 
)

Definition at line 15 of file volume_data.cpp.

References InitializeVolumeData().

                                                                      {
                        InitializeVolumeData(sizeX, sizeY, sizeZ, 1, 1, 1, 0, 0, 0, true, 0);
                }
VolumeData::VolumeData ( int  sizeX,
int  sizeY,
int  sizeZ,
float  val 
)

Definition at line 19 of file volume_data.cpp.

References InitializeVolumeData().

                                                                                 {
                        InitializeVolumeData(sizeX, sizeY, sizeZ, 1, 1, 1, 0, 0, 0, true, val);
                }
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.

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

                                                                                                                                {
                        InitializeVolumeData(sizeX, sizeY, sizeZ, data->GetSpacingX(), data->GetSpacingY(), data->GetSpacingZ(), data->GetOriginX(), data->GetOriginY(), data->GetOriginZ(), false, 0);
                        float value;
                        for ( int k = offsetZ; k < sizeZ + offsetZ; k++) {
                                for (int j = offsetY; j < sizeY + offsetY; j++ ) {
                                        for (int i = offsetX; i < sizeX + offsetX; i++) {
                                                value = data->GetDataAt(i,j,k);
                                                SetDataAt(i-offsetX,j-offsetY,k-offsetZ, value);
                                        }
                                }
                        }
                }
VolumeData::VolumeData ( VolumeData obj)

Definition at line 36 of file volume_data.cpp.

References emdata, get_emdata(), and owns_emdata.

                {
                        emdata = new EMData( *obj.get_emdata() );
                        owns_emdata = true;
                        //SetSize( obj.GetSizeX(), obj.GetSizeY(), obj.GetSizeZ() );
                        //SetSpacing( obj.GetSpacingX(), obj.GetSpacingY(), obj.GetSpacingZ() );
                        //SetOrigin( obj.GetOriginX(), GetOriginY(), obj.GetOriginZ() );
                }
VolumeData::~VolumeData ( )

Definition at line 44 of file volume_data.cpp.

References emdata, and owns_emdata.

                                        {
                        if (owns_emdata)
                                delete emdata;
                }

Member Function Documentation

EMData * VolumeData::get_emdata ( )

Definition at line 166 of file volume_data.cpp.

References emdata.

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

                {
                        return emdata;
                }
float VolumeData::GetDataAt ( int  x,
int  y,
int  z 
)

Definition at line 149 of file volume_data.cpp.

References emdata, and EMAN::EMData::get_value_at().

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

                                                               {
                        return this->emdata->get_value_at(x, y, z);
                }
float VolumeData::GetDataAt ( int  index)

Definition at line 153 of file volume_data.cpp.

References emdata, and EMAN::EMData::get_value_at().

                                                     {
                        //TODO: This may be a problem because EMAN2 and Gorgon do indexing differently --> see if this causes problems
                        return emdata->get_value_at(index);
                }
int VolumeData::GetIndex ( int  x,
int  y,
int  z 
)

Definition at line 158 of file volume_data.cpp.

References GetSizeX(), and GetSizeY().

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

                                                            {
                        return (x + y * GetSizeX() + z * GetSizeX() * GetSizeY());
                }
int VolumeData::GetMaxIndex ( )

Definition at line 162 of file volume_data.cpp.

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

                                            {
                        return GetSizeX() * GetSizeY() * GetSizeZ();
                }
float VolumeData::GetOrigin ( int  dimension)

Definition at line 119 of file volume_data.cpp.

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

                                                         {
                        float ret = 0;
                        switch (dimension)
                        {
                                case 0: ret = GetOriginX();
                                        break;
                                case 1: ret = GetOriginY();
                                        break;
                                case 2: ret = GetOriginZ();
                                        break;
                                default:
                                        throw InvalidParameterException("VolumeData::GetOrigin requires an argument of 0, 1, or 2");
                        }

                        return ret;
                }
float VolumeData::GetOriginX ( )

Definition at line 136 of file volume_data.cpp.

References emdata, and EMAN::EMData::get_attr().

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

                                             {
                        return emdata->get_attr("origin_x");
                }
float VolumeData::GetOriginY ( )

Definition at line 140 of file volume_data.cpp.

References emdata, and EMAN::EMData::get_attr().

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

                                             {
                        return emdata->get_attr("origin_y");
                }
float VolumeData::GetOriginZ ( )

Definition at line 144 of file volume_data.cpp.

References emdata, and EMAN::EMData::get_attr().

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

                                             {
                        return emdata->get_attr("origin_z");
                }
int VolumeData::GetSize ( int  dimension)

Definition at line 60 of file volume_data.cpp.

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

                                                     {
                        int ret = 0;
                        switch (dimension)
                        {
                                case 0: ret = GetSizeX();
                                        break;
                                case 1: ret = GetSizeY();
                                        break;
                                case 2: ret = GetSizeZ();
                                        break;
                                default:
                                        throw InvalidParameterException("VolumeData::GetSize requires an argument of 0, 1, or 2");
                        }

                        return ret;

                }
int VolumeData::GetSizeX ( )
int VolumeData::GetSizeY ( )
int VolumeData::GetSizeZ ( )

Definition at line 86 of file volume_data.cpp.

References emdata, and EMAN::EMData::get_zsize().

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

                                         {
                        return emdata->get_zsize();
                }
float VolumeData::GetSpacing ( int  dimension)

Definition at line 90 of file volume_data.cpp.

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

                                                          {
                        float ret = 0;
                        switch (dimension)
                        {
                                case 0: ret = GetSpacingX();
                                        break;
                                case 1: ret = GetSpacingY();
                                        break;
                                case 2: ret = GetSpacingZ();
                                        break;
                                default:
                                        throw InvalidParameterException("VolumeData::GetSpacing requires an argument of 0, 1, or 2");
                        }

                        return ret;
                }
float VolumeData::GetSpacingX ( )

Definition at line 107 of file volume_data.cpp.

References emdata, and EMAN::EMData::get_attr().

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

                                              {
                        return emdata->get_attr("apix_x");
                }
float VolumeData::GetSpacingY ( )

Definition at line 111 of file volume_data.cpp.

References emdata, and EMAN::EMData::get_attr().

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

                                              {
                        return emdata->get_attr("apix_y");
                }
float VolumeData::GetSpacingZ ( )

Definition at line 115 of file volume_data.cpp.

References emdata, and EMAN::EMData::get_attr().

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

                                              {
                        return emdata->get_attr("apix_y");
                }
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.

References emdata, owns_emdata, SetOrigin(), SetSpacing(), and EMAN::EMData::to_value().

Referenced by VolumeData().

                                                                                                                                                                                                                  {
                        emdata = new EMData(sizeX, sizeY, sizeZ);
                        owns_emdata = true;
                        //SetSize(sizeX, sizeY, sizeZ);
                        SetSpacing(spacingX, spacingY, spacingZ);
                        SetOrigin(originX, originY, originZ);
                        if(initializeData) {
                                emdata->to_value(val);
                        }
                }
void VolumeData::Pad ( int  padBy,
double  padValue 
)

Definition at line 196 of file volume_data.cpp.

References emdata, GetDataAt(), GetSizeX(), GetSizeY(), GetSizeZ(), EMAN::EMData::set_data(), SetSize(), x, and y.

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

                                                               {

                        int sizex = GetSizeX();
                        int sizey = GetSizeY();
                        int sizez = GetSizeZ();
                        int newSizeX = sizex + 2*padBy;
                        int newSizeY = sizey + 2*padBy;
                        int newSizeZ = sizez + 2*padBy;

                        // Method 1: Using get_clip ===========================================================
//                      Region reg(0, 0, 0, newSizeX, newSizeY, newSizeZ);
//                      EMData * new_emdata = emdata->get_clip(reg); //Extends the area x > sizex, y > sizey, z > sizez but does not translate (0,0,0)
//                      new_emdata->translate(padBy,padBy,padBy); //We want equal padding on each side
//
//                      for(int z = 0; z < newSizeZ; z++)
//                              for(int y = 0; y < newSizeY; y++)
//                                      for(int x = 0; x < newSizeX; x++)
//                                              if ((x < padBy) || (y < padBy) || (z < padBy) || (x >= padBy + sizex) || (y >= padBy + sizey) || (z >= padBy + sizez))
//                                                      new_emdata->set_value_at(x, y, z, padValue);
//
//                      if (this->owns_emdata)
//                              this->emdata->free_memory();
//                      this->emdata = new_emdata;

                        // Method 2: making a copy =============================================================
                        float * newData = (float*) malloc ( newSizeX * newSizeY * newSizeZ * sizeof(float) );
                        double value;

                        for(int z = 0; z < newSizeZ; z++) {
                                for(int y = 0; y < newSizeY; y++) {
                                        for(int x = 0; x < newSizeX; x++) {
                                                if ((x < padBy) || (y < padBy) || (z < padBy) || (x >= padBy + sizex) || (y >= padBy + sizey) || (z >= padBy + sizez)) {
                                                        value = padValue;
                                                } else {
                                                        value = GetDataAt(x-padBy, y-padBy, z-padBy);
                                                }

                                                newData[x + y * newSizeX + z * newSizeX * newSizeY] = static_cast<float>(value); //eman2
                                        }
                                }
                        }

                        SetSize(newSizeX, newSizeY, newSizeZ);
                        emdata->set_data(newData, newSizeX, newSizeY, newSizeZ);
                        //free(data); //I think this is handled by set_data

                        // Method 3: doing in-place resize =====================================================
//                      emdata->set_size(newSizeX, newSizeY, newSizeZ);
//                      double val;
//                      for (int k = newSizeZ - 1; k >= 0; k--)
//                              for (int j = newSizeY - 1; k >= 0; j--)
//                                      for (int i = newSizeX - 1; k >=0; k--)
//                                      {
//                                              if ( i < padBy || i >= sizex+padBy || j < padBy || j >= sizey+padBy || k < padBy || k >= sizez+padBy)
//                                                      emdata->set_value_at(i,j,k, padValue);
//                                              else
//                                              {
//                                                      val = emdata->get_value_at(i-padBy, j-padBy, k-padBy);
//                                                      emdata->set_value_at(i,j,k, float(val));
//                                              }
//                                      }
                }
void VolumeData::SetDataAt ( int  x,
int  y,
int  z,
float  value 
)

Definition at line 188 of file volume_data.cpp.

References emdata, and EMAN::EMData::set_value_at().

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

                                                                           {
                        emdata->set_value_at(x, y, z, value);
                }
void VolumeData::SetDataAt ( int  index,
float  value 
)

Definition at line 192 of file volume_data.cpp.

References emdata, and EMAN::EMData::get_data().

                                                                 {
                        //TODO: This may be a problem because EMAN2 and Gorgon do indexing differently --> see if this causes problems
                        emdata->get_data()[index] = value;
                }
void VolumeData::SetOrigin ( float  originX,
float  originY,
float  originZ 
)

Definition at line 177 of file volume_data.cpp.

References emdata, and EMAN::EMData::set_attr().

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

                                                                                      {
                        emdata->set_attr("origin_x", originX);
                        emdata->set_attr("origin_y", originY);
                        emdata->set_attr("origin_z", originZ);
                }
void VolumeData::SetSize ( int  sizeX,
int  sizeY,
int  sizeZ 
) [private]

Definition at line 184 of file volume_data.cpp.

References emdata, and EMAN::EMData::set_size().

Referenced by Pad().

                                                                        {
                        emdata->set_size(sizeX, sizeY, sizeZ);
                }
void VolumeData::SetSpacing ( float  spacingX,
float  spacingY,
float  spacingZ 
)

Definition at line 171 of file volume_data.cpp.

References emdata, and EMAN::EMData::set_attr().

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

                                                                                          {
                        emdata->set_attr("apix_x", spacingX);
                        emdata->set_attr("apix_y", spacingY);
                        emdata->set_attr("apix_z", spacingZ);
                }

Member Data Documentation

Definition at line 52 of file volume_data.h.

Referenced by InitializeVolumeData(), VolumeData(), and ~VolumeData().


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