Skip to content

Commit

Permalink
Update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
nghia-vo committed Jul 10, 2021
1 parent 6510da6 commit 93549b4
Show file tree
Hide file tree
Showing 32 changed files with 365 additions and 250 deletions.
4 changes: 2 additions & 2 deletions algotom/io/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

"""
Module for converting data type:
- Convert a list of tif files to a hdf/nxs file.
- Extract tif images from a hdf/nxs file.
- Convert a list of tif files to a hdf/nxs file.
- Extract tif images from a hdf/nxs file.
"""

import os
Expand Down
12 changes: 6 additions & 6 deletions algotom/io/loadersaver.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@

"""
Module for I/O tasks:
- Load data from an image file (tif, png, jpeg) or a hdf/nxs file.
- Get dataset information in a hdf/nxs file.
- Search for datasets in a hdf/nxs file.
- Save a 2D array as a tif image or 2D, 3D array to a hdf/nxs file.
- Search file names, make a file/folder name.
- Load distortion coefficients from a txt file.
- Load data from an image file (tif, png, jpeg) or a hdf/nxs file.
- Get dataset information in a hdf/nxs file.
- Search for datasets in a hdf/nxs file.
- Save a 2D array as a tif image or 2D, 3D array to a hdf/nxs file.
- Search file names, make a file/folder name.
- Load distortion coefficients from a txt file.
"""

import os
Expand Down
10 changes: 5 additions & 5 deletions algotom/post/postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

"""
Module of methods in the postprocessing stage:
- Get statistical information of reconstructed images or a dataset.
- Downsample 2D, 3D array, or a dataset.
- Rescale 2D, 3D array or a dataset to 8-bit or 16-bit data-type.
- Removing ring artifacts in a reconstructed image by transform back and forth
between the polar coordinates and the Cartesian coordinates.
- Get statistical information of reconstructed images or a dataset.
- Downsample 2D, 3D array, or a dataset.
- Rescale 2D, 3D array or a dataset to 8-bit or 16-bit data-type.
- Removing ring artifacts in a reconstructed image by transform back and
forth between the polar coordinates and the Cartesian coordinates.
"""

import os
Expand Down
20 changes: 10 additions & 10 deletions algotom/prep/calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@

"""
Module of calculation methods in the preprocessing stage:
- Calculating the center-of-rotation (COR) in a 180-degree scan using a
sinogram.
- Determining the overlap-side and overlap-area between images.
- Calculating the COR in a half-acquisition scan (360-degree scan with offset
COR).
- Using the similar technique as above to calculate the COR in a 180-degree scan
from two projections.
- Determining the relative translations between images using phase-correlation
technique.
- Calculating the COR in a 180-degree scan using phase-correlation technique.
- Calculating the center-of-rotation (COR) in a 180-degree scan using a
sinogram.
- Determining the overlap-side and overlap-area between images.
- Calculating the COR in a half-acquisition scan (360-degree scan with
offset COR).
- Using the similar technique as above to calculate the COR in a 180-degree
scan from two projections.
- Determining the relative translations between images using
phase-correlation technique.
- Calculating the COR in a 180-degree scan using phase-correlation technique.
"""

import numpy as np
Expand Down
16 changes: 8 additions & 8 deletions algotom/prep/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@

"""
Module of conversion methods in the preprocessing stage:
- Stitching images.
- Joining images if there is no overlapping.
- Converting a 360-degree sinogram with offset center-of-rotation (COR) to
a 180-degree sinogram.
- Extending a 360-degree sinogram with offset COR for direct reconstruction
instead of converting it to a 180-degree sinogram.
- Converting a 180-degree sinogram to a 360-sinogram.
- Generating a sinogram from a helical data.
- Stitching images.
- Joining images if there is no overlapping.
- Converting a 360-degree sinogram with offset center-of-rotation (COR) to
a 180-degree sinogram.
- Extending a 360-degree sinogram with offset COR for direct reconstruction
instead of converting it to a 180-degree sinogram.
- Converting a 180-degree sinogram to a 360-sinogram.
- Generating a sinogram from a helical data.
"""

import numpy as np
Expand Down
16 changes: 8 additions & 8 deletions algotom/prep/correction.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@

"""
Module of correction methods in the preprocessing stage:
- Flat-field correction.
- Distortion correction.
- MTF deconvolution.
- Tilted sinogram generation.
- Tilted 1D intensity-profile generation.
- Beam hardening correction.
- Flat-field correction.
- Distortion correction.
- MTF deconvolution.
- Tilted sinogram generation.
- Tilted 1D intensity-profile generation.
- Beam hardening correction.
"""

import numpy as np
Expand Down Expand Up @@ -60,8 +60,8 @@ def flat_field_correction(proj, flat, dark, ratio=1.0, use_dark=True,
options : dict, optional
Apply a zinger removal method and/or ring removal methods.
E.g option1={"method": "dezinger", "para1": 0.001, "para2": 1},
option2={"method": "remove_stripe_based_sorting",
"para1": 15, "para2": 1}
option2={"method": "remove_stripe_based_sorting", "para1": 15,
"para2": 1}
Returns
-------
Expand Down
4 changes: 2 additions & 2 deletions algotom/prep/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

"""
Module of filtering methods in the preprocessing stage:
- Fresnel filter (denoising or low-pass filter).
- Double-wedge filter.
- Fresnel filter (denoising or low-pass filter).
- Double-wedge filter.
"""

import numpy as np
Expand Down
8 changes: 4 additions & 4 deletions algotom/prep/removal.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

"""
Module of removal methods in the preprocessing stage:
- Many methods for removing stripe artifact in a sinogram (<-> ring artifact
in a reconstructed image).
- A zinger removal method.
- Blob removal methods.
- Many methods for removing stripe artifact in a sinogram (<-> ring artifact
in a reconstructed image).
- A zinger removal method.
- Blob removal methods.
"""

import numpy as np
Expand Down
8 changes: 4 additions & 4 deletions algotom/rec/reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

"""
Module of FFT-based reconstruction methods in the reconstruction stage:
- Filtered back-projection (FBP) method for GPU (using numba and cuda) and CPU.
- Direct Fourier inversion (DFI) method.
- Wrapper for Astra Toolbox reconstruction (optional)
- Wrapper for Tomopy-gridrec reconstruction (optional)
- Filtered back-projection (FBP) method for GPU (using numba and cuda) and CPU.
- Direct Fourier inversion (DFI) method.
- Wrapper for Astra Toolbox reconstruction (optional)
- Wrapper for Tomopy-gridrec reconstruction (optional)
"""

import math
Expand Down
8 changes: 4 additions & 4 deletions algotom/util/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

"""
Module of calibration methods:
- Correcting the non-uniform background of an image.
- Binarizing an image.
- Calculating the distance between two point-like objects segmented from
two images. Useful for determining pixel-size in helical scans.
- Correcting the non-uniform background of an image.
- Binarizing an image.
- Calculating the distance between two point-like objects segmented from
two images. Useful for determining pixel-size in helical scans.
"""

import numpy as np
Expand Down
44 changes: 18 additions & 26 deletions algotom/util/config.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# ============================================================================
# Author: Francesco De Carlo
# Description: Configuration module
# Contributors:
# ============================================================================

import os
import sys
import pathlib
import argparse
import configparser
import numpy as np
from collections import OrderedDict
from pathlib import Path

from algotom.util import log

LOGS_HOME = Path.home()/'logs'
LOGS_HOME = Path.home() / 'logs'
CONFIG_FILE_NAME = os.path.join(str(pathlib.Path.home()), 'algotom.conf')

SECTIONS = OrderedDict()

SECTIONS['general'] = {
'config': {
'default': CONFIG_FILE_NAME,
Expand All @@ -39,13 +41,11 @@
'type': str,
'default': "D:/output/",
'help': "string"},
}


EXPLORE_PARAMS = ('explore', )

}
EXPLORE_PARAMS = ('explore',)
NICE_NAMES = ('General', 'Explore')


def get_config_name():
"""Get the command line --config option."""
name = CONFIG_FILE_NAME
Expand All @@ -58,7 +58,6 @@ def get_config_name():
if name[0] == '=':
name = name[1:]
return name

return name


Expand All @@ -72,10 +71,9 @@ def parse_known_args(parser, subparser=False):
subparser_value = [sys.argv[1]] if subparser else []
config_values = config_to_list(config_name=get_config_name())
values = subparser_value + config_values + sys.argv[1:]
#print(subparser_value, config_values, values)
# print(subparser_value, config_values, values)
else:
values = ""

return parser.parse_known_args(values)[0]


Expand All @@ -87,34 +85,30 @@ def config_to_list(config_name=CONFIG_FILE_NAME):
"""
result = []
config = configparser.ConfigParser()

if not config.read([config_name]):
return []

for section in SECTIONS:
for name, opts in ((n, o) for n, o in SECTIONS[section].items() if config.has_option(section, n)):
for name, opts in ((n, o) for n, o in SECTIONS[section].items() if
config.has_option(section, n)):
value = config.get(section, name)

if value != '' and value != 'None':
action = opts.get('action', None)

if action == 'store_true' and value == 'True':
# Only the key is on the command line for this action
result.append('--{}'.format(name))

if not action == 'store_true':
if opts.get('nargs', None) == '+':
result.append('--{}'.format(name))
result.extend((v.strip() for v in value.split(',')))
else:
result.append('--{}={}'.format(name, value))

return result


class Params(object):
def __init__(self, sections=()):
self.sections = sections + ('general', )
self.sections = sections + ('general',)

def add_parser_args(self, parser):
for section in self.sections:
Expand All @@ -129,7 +123,6 @@ def add_arguments(self, parser):
def get_defaults(self):
parser = argparse.ArgumentParser()
self.add_arguments(parser)

return parser.parse_args('')


Expand All @@ -144,16 +137,15 @@ def write(config_file, args=None, sections=None):
for section in SECTIONS:
config.add_section(section)
for name, opts in SECTIONS[section].items():
if args and sections and section in sections and hasattr(args, name.replace('-', '_')):
if (args and sections and section in sections) \
and hasattr(args, name.replace('-', '_')):
value = getattr(args, name.replace('-', '_'))
if isinstance(value, list):
# print(type(value), value)
value = ', '.join(value)
else:
value = opts['default'] if opts['default'] is not None else ''

prefix = '# ' if value == '' else ''

if name != 'config':
config.set(section, prefix + name, str(value))
with open(config_file, 'w') as f:
Expand Down Expand Up @@ -187,11 +179,11 @@ def show_config(args):

log.warning('algotom status start')
for section, name in zip(SECTIONS, NICE_NAMES):
entries = sorted((k for k in args.keys() if k.replace('_', '-') in SECTIONS[section]))
entries = sorted((k for k in args.keys() if
k.replace('_', '-') in SECTIONS[section]))
if entries:
for entry in entries:
value = args[entry] if args[entry] != None else "-"
log.info(" {:<16} {}".format(entry, value))

log.warning('algotom status end')

6 changes: 3 additions & 3 deletions algotom/util/log.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'''
tomoscan custom logger
Logger
'''
import logging

Expand All @@ -24,7 +23,8 @@ def setup_custom_logger(lfname=None, stream_to_console=True):

if (lfname != None):
fHandler = logging.FileHandler(lfname)
file_formatter = logging.Formatter('%(asctime)s - %(levelname)s: %(message)s')
file_formatter = logging.Formatter('%(asctime)s - %(levelname)s:'
' %(message)s')
fHandler.setFormatter(file_formatter)
logger.addHandler(fHandler)
if stream_to_console:
Expand Down
8 changes: 4 additions & 4 deletions algotom/util/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@

"""
Module of simulation methods:
1- Methods for designing a customized 2D phantom.
2- Method for calculating a sinogram of a phantom based on the Fourier
slice theorem.
3- Methods for adding artifacts to a simulated sinogram.
- Methods for designing a customized 2D phantom.
- Method for calculating a sinogram of a phantom based on the Fourier
slice theorem.
- Methods for adding artifacts to a simulated sinogram.
"""

import numpy as np
Expand Down

0 comments on commit 93549b4

Please sign in to comment.