Skip to content
Snippets Groups Projects
Commit a8188939 authored by marco's avatar marco
Browse files

updated docs, added some more properties to image

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2495 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent 11e67f1c
No related branches found
No related tags found
No related merge requests found
......@@ -72,7 +72,7 @@ Isosurfaces are easy to create in OpenStructure:
The other way to visualize a 3-dimensional map is by showing one 2-dimensional
density slice at a time, allowing the user to move through the slices. In
OpenStructure this is achieved using a DataViewer :doc:`gui/image-viewer`).
OpenStructure this is achieved using a DataViewer).
A DataViewer showing the filtered map is created using the following command:
.. code-block:: python
......
......@@ -14,7 +14,7 @@ for the platform-independent data like icons, images and examples.
OpenStructure uses `CMake <http://www.cmake.org>`_ to build the project. The
rules for the build-system are defined in `CMakeLists.txt` files. When running
`CMake <http://cmake.org>`_, the files are compiled and copied into stage. The
`cmake`, the files are compiled and copied into stage. The
real installation, if necessary, happens at a later stage. This is referred to
as staging of the files.
......
......@@ -2,7 +2,6 @@ Vectors
================================================================================
.. currentmodule:: ost.geom
The :class:`Vec2`, :class:`Vec3`, :class:`Vec4` classes implement vectors in 2,
3 and four dimensions. They support basic arithmetic via overloaded operators.
Essentially, the following basic operations are available:
......
......@@ -193,6 +193,7 @@ It is interesting to note that the offset from center (`trans`) is given in rota
.. method:: GetFOV()
Get the field of view angle in the y direction (in degrees).
:rtype: float
.. method:: GetRTC()
......@@ -201,7 +202,7 @@ It is interesting to note that the offset from center (`trans`) is given in rota
Looks stale. Remove it?
:rtype: :class:`Mat4`
:rtype: :class:`~ost.geom.Mat4`
.. method:: GetTransform()
......@@ -310,7 +311,7 @@ It is interesting to note that the offset from center (`trans`) is given in rota
.. method:: SetRTC(arg2)
:param arg2:
:type arg2: :class:`Mat4`
:type arg2: :class:`~ost.geom.Mat4`
.. method:: SetShadow(arg2)
......
:mod:`~ost.img` - Images and Density Maps
================================================================================
.. toctree::
:hidden:
point-size-extent
.. module:: ost.img
:synopsis: Images and density maps
......@@ -32,17 +37,17 @@ Creating and visualizing ImageHandles
As a first step, enter the following lines in the OpenStructure python console:
.. code-block:: python
.. code-block:: python
im=img.CreateImage(img.Size(200,200))
im=img.CreateImage(img.Size(200,200))
This will create an empty, 2D image, with a height and width of 200 pixels,
whose origin (ie the pixel with the coordinates <0,0>) is in the top-left
corner.
.. code-block:: python
.. code-block:: python
v=gui.CreateDataViewer(im)
v=gui.CreateDataViewer(im)
A viewer window will pop up (see below), showing a white frame on a black
background. The inner area of the white frame is the image, which is empty.
......@@ -53,21 +58,21 @@ Reading and writing into an image
Data can be read and written from and into an image using the following
commands:
.. code-block:: python
# writes the real value 23.4 into pixel 10,10
im.SetReal(img.Point(10,10),23.4)
# reads the value in pixel 10,10
val=im.GetReal(img.Point(10,10))
.. code-block:: python
# writes the real value 23.4 into pixel 10,10
im.SetReal(img.Point(10,10),23.4)
# reads the value in pixel 10,10
val=im.GetReal(img.Point(10,10))
The complex equivalents are also available
.. code-block:: python
# writes the complex value value 2+3j into pixel 10,10
im.SetComplex(img.Point(10,10),2+3j)
# reads the value in pixel 10,10
val=im.GetComplex(img.Point(10,10))
.. code-block:: python
# writes the complex value value 2+3j into pixel 10,10
im.SetComplex(img.Point(10,10),2+3j)
# reads the value in pixel 10,10
val=im.GetComplex(img.Point(10,10))
The image knows in which domain it is, and will adjust the type of data being
written accordingly. For example, if one writes a complex value in a
......@@ -79,180 +84,114 @@ converted to complex by setting the imaginary part to 0.
Image properties
-----------------
Every 2D or 3D image in OpenStructure has some basic properties, which are discussed in detail in the next paragraphs.
Point
^^^^^^^^
.. class:: Point(x=0, y=0, z=0)
This class represents an image pixel. It is defined using three integer
numbers, corresponding to the pixel’s indexes along the weight and depth
dimensions respectively.
Size
^^^^^^^^
.. class:: Size(width, height, depth)
Size(width, height)
This property describes the size of an image. It is defined using three
integer numbers: When depth is not specified, the size is assumed to refer to
a 2D image two-dimensional (depth=1).
The :class:`Size` class can be passed to the :func:`CreateImage` function to
define the size of the image being created.
.. code-block:: python
# uses the size class to create an image
s=img.Size(40,20,30)
i=img.CreateImage(s)
# uses a temporary instance of the Size class
i=img.CreateImage(img.Size(40,20,30))
Extent
^^^^^^^^
.. class:: Extent(first_point, last_point)
Extent(first_point, size)
Extent(size, center_point)
This property describes the extent of an image in pixels. The image extent is
a rectangle in 2d and a cuboid in 3d, and can be defined in a number of ways:
giving the first and the last point of the extent, specifying the first point
and the size of the extent, or listing the size of the extent and its central
point.
Some examples:
.. _data-domain:
.. code-block:: python
The data domain
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# defines a rectangular extent that goes from pixel (2,4) to pixel (5,10)
s=img.Extent(img.Point(2,4),img.Point(5,10))
# defines the same extent using its first point and its size
s=img.Extent(img.Point(2,4),img.Size(4,7))
# again the same extent using its size and central pixel
s=img.Extent(img.Size(4,7),img.Point(3,7))
The data domain of an image specifies wether the image contains data in the
spatial or frequency domain. A :obj:`HALF_FREQUENCY` domain also exists,
representing centrosymmetric frequency data (such as the data coming from the
Fourier transform of an image from the real spatial domain)
The :class:`Extent` class can be passed to the :func:`CreateImage` function to
create an image with a specific extent.
.. data:: SPATIAL
.. code-block:: python
Real-valued spatial images
# uses the Extent class to create an image
e=img.Extent(img.Point(2,4),img.Size(4,7))
i=img.CreateImage(e)
# uses a temporary instance of the Extent class
i=img.CreateImage(img.Extent(img.Point(2,4),img.Size(4,7)))
.. data:: COMPLEX_SPATIAL
Given an :class:`Extent`, is it possible to recover its full size, and also
the length of each of its dimensions separately.
Complex-valued spatial images, i.e. resulting from a Fourier transform of
the :obj:`FREQUENCY` domain.
.. data:: FREQUENCY
Complex frequeny domain.
.. data:: HALF_FREQUENCY
Examples:
Centrosymmetric frequency images
.. code-block:: python
# gets the size of an extent (e is a 3D extent)
s=e.GetSize()
# gets the three dimensions separately
w=e.GetWidth()
h=e.GetHeight()
d=e.GetDepth()
.. _spatial-origin:
When one needs to visit all the image pixels belonging to an :class:`Extent`
in sequence, one can use an :class:`ExtentIterator`:
The spatial origin
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
The spatial origin of an image is the first pixel of its extent. Specifically,
this is the top left pixel for 2D images and the top-front-left corner for 3D
images.
# defines an iterator over an extent e
ei=ExtentIterator(e)
# visits all the pixels in the extent and
# prints out their values
for pixel in ei:
print i.GetReal(pixel)
.. _absolute-origin:
.. _data-type:
The absolute origin
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
DataType
^^^^^^^^
The absolute origin of an image describes the coordinates, in the absolute
reference system used by OpenStructure, of the pixel in with all indexes equal
to 0. Please note that the pixel does not necessarily need to belong to the
extent of the image.
The DataType of an image represents the nature of the data it contains. An image can contain 'REAL' or :obj:`COMPLEX` values.
.. _pixel-sampling:
.. _data-domain:
Pixel sampling
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
DataDomain
^^^^^^^^^^
The data domain of an image specifies wether the image contains data in the
spatial or frequency domain. A :obj:`HALF_FREQUENCY` domain also exists,
representing centrosymmetric frequency data (such as the data coming from the
Fourier transform of an image from the real spatial domain)
The pixel sampling property of an image describes the size of its pixels. For
the same image, the size of pixels in the :obj:`SPATIAL` and in the
:obj:`FREQUENCY` :ref:`data-domain` are obviously interdependent.
OpenStructure takes care of the transformation and allows access to both pixel
sampling irrespective of the current image domain.
.. data:: SPATIAL
The ImageHandle class
--------------------------------------------------------------------------------
Real-valued spatial images
The public interface of the ImageHandle class provides many ways to manipulate
image properties. What follows is a brief description of the most important
methods and attributes of the ImageHandle class.
.. data:: COMPLEX_SPATIAL
.. class:: ImageHandle
Complex-valued spatial images, i.e. resulting from a Fourier transform of
the :obj:`FREQUENCY` domain.
.. attribute:: size
The size of the image. Read-only.
.. data:: FREQUENCY
:type: :class:`Size`
Complex frequeny domain.
.. attribute:: extent
The extent of the image. Read-only.
.. data:: HALF_FREQUENCY
:type: :class:`Extent`
Centrosymmetric frequency images
.. attribute:: type
The DataType of an image represents the nature of the data it contains. An
image can contain :obj`REAL` or :obj:`COMPLEX` values.
.. attribute:: absolute_origin
The absolute origin of an image describes the coordinates, in the absolute
reference system used by OpenStructure, of the pixel in with all indexes
equal to 0. Please note that the pixel does not necessarily need to belong
to the extent of the image. Read-write.
:type: :class:`~ost.geom.Vec3`
.. attribute:: spatial_origin
The spatial origin of an image is the first pixel of its extent.
Specifically, this is the top left pixel for 2D images and the
top-front-left corner for 3Dimages.
:type: :class:`Point`
.. _spatial-origin:
SpatialOrigin
^^^^^^^^^^^^^^
Type: :class:`Point`
The spatial origin of an image is the first pixel of its extent. Specifically,
this is the top left pixel for 2D images and the top-front-left corner for 3D
images.
.. _absolute-origin:
AbsoluteOrigin
^^^^^^^^^^^^^^^^
Type: :class:`~ost.geom.Vec3`
The absolute origin of an image describes the coordinates, in the absolute
reference system used by OpenStructure, of the pixel in with all indexes equal
to 0. Please note that the pixel does not necessarily need to belong to the
extent of the image.
.. _pixel-sampling:
PixelSampling
^^^^^^^^^^^^^^^^^
Type: :class:`~ost.geom.Vec3`
The pixel sampling property of an image describes the size of its pixels. For
the same image, the size of pixels in the :obj:`SPATIAL` and in the
:obj:`FREQUENCY` :ref:`data-domain` are obviously interdependent.
OpenStructure takes care of the transformation and allows access to both pixel
sampling irrespective of the current image domain.
ImageHandle
-----------
The public interface of the ImageHandle class provides many ways to manipulate image properties. What follows is a brief description of the most important methods of the
ImageHandle class.
.. class:: ImageHandle
.. attribute:: domain
The current domain of the image. See :ref:`data-domain`. Read-only.
.. method:: Apply(algorithm)
......@@ -300,10 +239,10 @@ ImageHandle class.
Creates and returns a new image that contains a copy of a portion of the
original image. The extracted image keeps the same :ref:`data-type` of the
original image, but extractions from images in the 'FREQEUNCY' or
'HALF FREQUENCY' domains result in :obj:`COMPLEX ` :obj:`SPATIAL` images. This
transformation is necessary, since the there is no guarantee that the
extracted :obj:`FREQUENCY` sub-image is centered around the origin and hence
back-transformable to :obj:`SPATIAL`.
'HALF FREQUENCY' domains result in :obj:`COMPLEX ` :obj:`SPATIAL` images.
This transformation is necessary, since the there is no guarantee that the
extracted :obj:`FREQUENCY` sub-image is centered around the origin and
hence back-transformable to :obj:`SPATIAL`.
:param extent: Portion of the image to extract
:type extent: :class:`Extent`
......@@ -326,8 +265,9 @@ ImageHandle class.
.. method:: GetComplex(pixel)
Returns the complex value of the specified image pixel. If the image holds data of the 'REAL' :ref:`data-type`, the method return s complex value with the pixel content
as real part and a null imaginary part.
Returns the complex value of the specified image pixel. If the image holds
data of the 'REAL' :ref:`data-type`, the method return s complex value with
the pixel content as real part and a null imaginary part.
:param pixel: Image pixel
:type pixel: :class:`Point`
......@@ -335,16 +275,12 @@ ImageHandle class.
.. method:: GetDomain()
Returns the :ref:`data-domain` of an image (:obj:`SPATIAL`,
:obj:`FREQUENCY`or :obj:`HALF_FREQUENCY`)
:rtype: DataDomain ???????????
See :attr:`domain`
.. method:: GetExtent()
Returns the :class:`Extent` of an image.
See :attr:`extent`
:rtype: :class:`Extent`
.. method:: GetFrequencySampling()
......@@ -372,9 +308,9 @@ ImageHandle class.
Returns the interpolated value of the virtual pixel corresponding to the
specified fractional indexes. This is computed by using bilinear
interpolation (trilinear for 3D images). If the image holds data of the
:obj:`COMPLEX ` :ref:`data-type`, the method computes the interpolated value as a
weighted vector sum of the values of the surrounding pixels, then returns
the amplitude of the interpolated value.
:obj:`COMPLEX ` :ref:`data-type`, the method computes the interpolated
value as a weighted vector sum of the values of the surrounding pixels,
then returns the amplitude of the interpolated value.
:param frac_pixel: Fractional pixel indexes
:type frac_pixel: :class:`~ost.geom.Vec3`
......@@ -390,8 +326,8 @@ ImageHandle class.
.. method:: GetReal(pixel)
Returns the value of the specified image pixel. If the image holds data of
the :obj:`COMPLEX ` :ref:`data-type`, the method return the amplitude of the
pixel content.
the :obj:`COMPLEX ` :ref:`data-type`, the method return the amplitude of
the pixel content.
:param pixel: Image pixel
:type pixel: :class:`Point`
......
Point, Size, Extent
================================================================================
.. currentmodule:: ost.img
This document describes some of the classes used in the :mod`~ost.img` module to describe image properties such as size, pixel coordinates and extents.
Point
--------------------------------------------------------------------------------
.. class:: Point(x=0, y=0, z=0)
Point(vec)
Point(size)
Point(point)
:param x: integral x coordinate
:type x: int
:param y: integral y coordinate
:type y: int
:param z: integral z coordinate
:type z: int
:param vec: The vectors coordinates will be rounded to the next
integral value. In case of a :class:`~ost.geom.Vec4`, the coordinates will
be divided by the homogenous coordinate.
:type vec: :class:`~ost.geom.Vec3`, :class:`~ost.geom.Vec4`
:param point:
:type point: Initialize from point
This class represents an image pixel. It is defined using three integer
numbers, corresponding to the pixel’s indexes along the width, height and
depth dimensions respectively.
.. method:: __getitem__(index)
Read-write access to the coordinates.
..code-block:: python
p=img.Point(1,2,3)
print p
p[1]=5
.. method:: ToVec3()
Converts the point to a :class:`~ost.geom.Vec3`
.. method:: ToVec2()
Converts the point to a :class:`~ost.geom.Vec2`. The z coordinate of the
point is ommitted.
.. method:: ToVec4()
Converts the point to a :class:`~ost.geom.Vec4`, with the homogenous
coordinate set to 1.
Size
--------------------------------------------------------------------------------
.. class:: Size(width, height, depth)
Size(width, height)
This property describes the size of an image. It is defined using three
integer numbers: When depth is not specified, the size is assumed to refer to
a 2D image two-dimensional (depth=1).
The :class:`Size` class can be passed to the :func:`CreateImage` function to
define the size of the image being created.
.. code-block:: python
# uses the size class to create an image
s=img.Size(40,20,30)
i=img.CreateImage(s)
# uses a temporary instance of the Size class
i=img.CreateImage(img.Size(40,20,30))
Extent
--------------------------------------------------------------------------------
.. class:: Extent(first_point, last_point)
Extent(first_point, size)
Extent(size, center_point)
This class describes the extent of an image in pixels. The image extent is
a rectangle in 2d and a cuboid in 3d, and can be defined in a number of ways:
giving the first and the last point of the extent, specifying the first point
and the size of the extent, or listing the size of the extent and its central
point.
**Some examples:**
.. code-block:: python
# defines a rectangular extent that goes from pixel (2,4) to pixel (5,10)
s=img.Extent(img.Point(2,4),img.Point(5,10))
# defines the same extent using its first point and its size
s=img.Extent(img.Point(2,4),img.Size(4,7))
# again the same extent using its size and central pixel
s=img.Extent(img.Size(4,7),img.Point(3,7))
The :class:`Extent` class can be passed to the :func:`CreateImage` function to
create an image with a specific extent.
.. code-block:: python
# uses the Extent class to create an image
e=img.Extent(img.Point(2,4),img.Size(4,7))
i=img.CreateImage(e)
# uses a temporary instance of the Extent class
i=img.CreateImage(img.Extent(img.Point(2,4),img.Size(4,7)))
Given an :class:`Extent`, is it possible to recover its full size, and also
the length of each of its dimensions separately.
**Examples:**
.. code-block:: python
# gets the size of an extent (e is a 3D extent)
s=e.GetSize()
# gets the three dimensions separately
w=e.GetWidth()
h=e.GetHeight()
d=e.GetDepth()
When one needs to visit all the image pixels belonging to an :class:`Extent`
in sequence, one can use an :class:`ExtentIterator`:
.. code-block:: python
# defines an iterator over an extent e
ei=ExtentIterator(e)
# visits all the pixels in the extent and
# prints out their values
for pixel in ei:
print i.GetReal(pixel)
\ No newline at end of file
......@@ -61,6 +61,7 @@ void export_Data()
class_<ConstData, boost::noncopyable>("ConstData", no_init )
.def("GetType",&ConstData::GetType)
.add_property("type", &ConstData::GetType)
.def("GetDomain",&ConstData::GetDomain)
.def("GetExtent",&ConstData::GetExtent)
.def("GetReal",&ConstData::GetReal)
......
......@@ -2,47 +2,92 @@ OpenStructure documentation
================================================================================
.. toctree::
:hidden:
:maxdepth: 1
Introduction
--------------------------------------------------------------------------------
.. toctree::
:maxdepth: 2
install
intro
Modules
--------------------------------------------------------------------------------
.. toctree::
:maxdepth: 1
base/generic
base/base
geom/geom
mol/base/mol
conop/conop
img/base/img
img/alg/alg
seq/base/seq
io/io
gfx/gfx
gui/gui
newmodule
external
For Starters
--------------------------------------------------------------------------------
**Installation**: :doc:`install`
**Tutorial Style**: :doc:`introduction <intro>` | :doc:`molecules intro <intro-01>` | :doc:`images intro <intro-02>` | :doc:`graphics intro <intro-03>`
Molecules
--------------------------------------------------------------------------------
**Overview**: :doc:`molecules intro <intro-01>` | :doc:`mol overview <mol/base/mol>` | :doc:`graphical entity<gfx/entity>` | :doc:`entity <mol/base/entity>`
**Input/Output**: :ref:`loading and saving molecules <mol-io>`
**Connectivity**: :doc:`the conop module <conop/conop>`
Images
--------------------------------------------------------------------------------
**Overview**: :doc:`images intro <intro-02>` | :doc:`img module <img/base/img>` | :doc:`img.alg module <img/alg/alg>`
Sequences and Alignments
--------------------------------------------------------------------------------
**Overview**: :doc:`sequence module <seq/base/seq>`
**Input/Output**: :ref:`loading and saving sequences <seq-io>`
Graphics
--------------------------------------------------------------------------------
**Overview** :doc:`graphics intro <intro-03>`
**Main Classes**: :doc:`the scene <gfx/scene>` | :doc:`graphical entity <gfx/entity>`
Graphical User Interface
--------------------------------------------------------------------------------
**Overview**: :doc:`module overview <gui/gui>` | :doc:`organization <gui/layout>` :doc:`tools <gui/tools>`
**Widgets**: :doc:`python shell <gui/python_shell>` | :doc:`sequence viewer <gui/sequence_viewer>`
Extending OpenStructure
--------------------------------------------------------------------------------
.. toctree::
:maxdepth: 1
newmodule
external
**Howto:** :doc:`write new modules <newmodule>` | :doc:`integrate third-party tools <external>`
\ No newline at end of file
:mod:`~ost.io` - Input and Output of Sequences, Structures and Maps
================================================================================
.. toctree::
:hidden:
formats
.. module:: ost.io
:synopsis: Input and output of sequences, alignments, structures, images and density maps.
......@@ -12,6 +17,8 @@ such as PDB, SDF and CHARMM trajectory files are available. Sequence and
alignment file formats such as FASTA and CLUSTALW are supported as well as
various image data (e.g. png, dm3) and density map files (e.g. CCP4, MRC).
.. _mol-io:
Molecular Structures
--------------------------------------------------------------------------------
......@@ -103,12 +110,16 @@ file:
.. autofunction:: ost.io.SavePDB
.. _seq-io:
Sequences and Alignments
--------------------------------------------------------------------------------
Loading sequence or alignment files
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. function:: LoadSequence(filename, format='auto')
Load sequence data from disk. If format is set to 'auto', the function guesses
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment