Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8272336
add fourier Filter
mittoalb Mar 25, 2024
4fd1a7e
Merge branch 'tomography:main' into main
mittoalb Mar 25, 2024
74e6192
Merge branch 'tomography:main' into main
mittoalb Apr 4, 2024
46157cd
bug fix
mittoalb Apr 16, 2024
684e7db
Merge branch 'tomography:main' into main
mittoalb Sep 10, 2024
af13b22
add phase method
mittoalb Sep 10, 2024
41c5307
zarr Reader, various phase-retrievals
mittoalb Oct 25, 2024
9a83080
config fix
mittoalb Oct 25, 2024
005a1bf
Merge pull request #1 from mittoalb/dev
mittoalb Oct 25, 2024
355899a
code cleanup
mittoalb Oct 29, 2024
bd58e07
Merge pull request #2 from mittoalb/dev
mittoalb Oct 29, 2024
291dfbb
code cleanup
mittoalb Oct 30, 2024
104dda2
Merge pull request #3 from mittoalb/dev
mittoalb Oct 30, 2024
e8c3abb
add zarr dependency
nikitinvv Nov 11, 2024
a2b5719
checking write with zarr
nikitinvv Nov 11, 2024
6f4b501
Merge pull request #4 from tomography/pullcheck
mittoalb Nov 11, 2024
af7e184
solved bug in zarr data saving
mittoalb Nov 21, 2024
824a800
recon steps zarr data saving
mittoalb Nov 22, 2024
9c374cb
Meta saving
mittoalb Nov 25, 2024
c32cfad
Updated meta saving
mittoalb Nov 26, 2024
36b1d4a
Updated meta saving
mittoalb Nov 26, 2024
b7d9cc3
Fixed zarr data neuroglancer compatibility
mittoalb Nov 27, 2024
7867104
Updated meta saving
mittoalb Dec 4, 2024
abd2dbf
bugs over bugs
mittoalb Dec 6, 2024
02de7d8
clean up
mittoalb Dec 6, 2024
3a92c83
clean up
mittoalb Dec 6, 2024
7f9d08a
Restructured/add zarr sum data
mittoalb Dec 11, 2024
1d2461d
MIP alignment
mittoalb Feb 8, 2025
3b54b49
Merge pull request #11 from mittoalb/dev
mittoalb Feb 8, 2025
09e30da
Refactor stripe removal functions for 3D input
mittoalb Mar 4, 2026
338ebfc
Add shebang and license information to __init__.py
mittoalb Mar 4, 2026
43962ef
Update CUDA architectures for multiple targets
mittoalb Mar 4, 2026
093bda3
Add build system configuration to pyproject.toml
mittoalb Mar 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.4
1.0.6
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["scikit-build", "cmake", "ninja"]
build-backend = "setuptools.build_meta"
3 changes: 2 additions & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ requirements:
- opencv
- opencv-contrib-python
- pywavelets
- tifffile
- tifffile
- zarr

about:
home: https://github.com/tomography/tomocupy
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
packages=find_packages('src'),
zip_safe=False,
install_requires=[
'cupy',
'cupy',
'opencv-python',
'h5py',
'numexpr',
'numpy',
'pywavelets',
'setuptools', # for pkg_resources at runtime
'tifffile',
'zarr',
]
)
22 changes: 11 additions & 11 deletions src/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,59 +19,59 @@ include_directories(${PYTHON_INCLUDE_PATH})
set_source_files_properties(cfunc_fourierrec.i PROPERTIES CPLUSPLUS ON)
swig_add_library(cfunc_fourierrec LANGUAGE python SOURCES cfunc_fourierrec.i cfunc_fourierrec.cu)
swig_link_libraries(cfunc_fourierrec cudart cufft Python::Module)
set_target_properties(cfunc_fourierrec PROPERTIES CUDA_ARCHITECTURES "60;72;75;80")
set_target_properties(cfunc_fourierrec PROPERTIES CUDA_ARCHITECTURES "75;80")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cfunc_fourierrec.py" DESTINATION tomocupy)
install(TARGETS cfunc_fourierrec LIBRARY DESTINATION tomocupy)

set_source_files_properties(cfunc_lprec.i PROPERTIES CPLUSPLUS ON)
swig_add_library(cfunc_lprec LANGUAGE python SOURCES cfunc_lprec.i cfunc_lprec.cu)
swig_link_libraries(cfunc_lprec cudart cufft Python::Module)
set_target_properties(cfunc_lprec PROPERTIES CUDA_ARCHITECTURES "60;72;75;80")
set_target_properties(cfunc_lprec PROPERTIES CUDA_ARCHITECTURES "75;80")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cfunc_lprec.py" DESTINATION tomocupy)
install(TARGETS cfunc_lprec LIBRARY DESTINATION tomocupy)

set_source_files_properties(cfunc_linerec.i PROPERTIES CPLUSPLUS ON)
swig_add_library(cfunc_linerec LANGUAGE python SOURCES cfunc_linerec.i cfunc_linerec.cu)
swig_link_libraries(cfunc_linerec cudart Python::Module)
set_target_properties(cfunc_linerec PROPERTIES CUDA_ARCHITECTURES "60;72;75;80")
set_target_properties(cfunc_linerec PROPERTIES CUDA_ARCHITECTURES "75;80")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cfunc_linerec.py" DESTINATION tomocupy)
install(TARGETS cfunc_linerec LIBRARY DESTINATION tomocupy)

set_source_files_properties(cfunc_filter.i PROPERTIES CPLUSPLUS ON)
swig_add_library(cfunc_filter LANGUAGE python SOURCES cfunc_filter.i cfunc_filter.cu)
swig_link_libraries(cfunc_filter cudart cufft Python::Module)
set_target_properties(cfunc_filter PROPERTIES CUDA_ARCHITECTURES "60;72;75;80")
set_target_properties(cfunc_filter PROPERTIES CUDA_ARCHITECTURES "75;80")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cfunc_filter.py" DESTINATION tomocupy)
install(TARGETS cfunc_filter LIBRARY DESTINATION tomocupy)

set_source_files_properties(cfunc_fourierrecfp16.i PROPERTIES CPLUSPLUS ON)
swig_add_library(cfunc_fourierrecfp16 LANGUAGE python SOURCES cfunc_fourierrecfp16.i cfunc_fourierrec.cu)
swig_link_libraries(cfunc_fourierrecfp16 cudart cufft Python::Module)
set_target_properties(cfunc_fourierrecfp16 PROPERTIES CUDA_ARCHITECTURES "60;72;75;80")
set_target_properties(cfunc_fourierrecfp16 PROPERTIES CUDA_ARCHITECTURES "75;80")
target_compile_definitions(cfunc_fourierrecfp16 PRIVATE HALF)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cfunc_fourierrecfp16.py" DESTINATION tomocupy)
install(TARGETS cfunc_fourierrecfp16 LIBRARY DESTINATION tomocupy)

set_source_files_properties(cfunc_lprecfp16.i PROPERTIES CPLUSPLUS ON)
swig_add_library(cfunc_lprecfp16 LANGUAGE python SOURCES cfunc_lprecfp16.i cfunc_lprec.cu)
swig_link_libraries(cfunc_lprecfp16 cudart cufft Python::Module)
set_target_properties(cfunc_lprecfp16 PROPERTIES CUDA_ARCHITECTURES "60;72;75;80")
set_target_properties(cfunc_lprecfp16 PROPERTIES CUDA_ARCHITECTURES "75;80")
target_compile_definitions(cfunc_lprecfp16 PRIVATE HALF)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cfunc_lprecfp16.py" DESTINATION tomocupy)
install(TARGETS cfunc_lprecfp16 LIBRARY DESTINATION tomocupy)

set_source_files_properties(cfunc_linerecfp16.i PROPERTIES CPLUSPLUS ON)
swig_add_library(cfunc_linerecfp16 LANGUAGE python SOURCES cfunc_linerecfp16.i cfunc_linerec.cu)
swig_link_libraries(cfunc_linerecfp16 cudart Python::Module)
set_target_properties(cfunc_linerecfp16 PROPERTIES CUDA_ARCHITECTURES "60;72;75;80")
set_target_properties(cfunc_linerecfp16 PROPERTIES CUDA_ARCHITECTURES "75;80")
target_compile_definitions(cfunc_linerecfp16 PRIVATE HALF)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cfunc_linerecfp16.py" DESTINATION tomocupy)
install(TARGETS cfunc_linerecfp16 LIBRARY DESTINATION tomocupy)

set_source_files_properties(cfunc_filterfp16.i PROPERTIES CPLUSPLUS ON)
swig_add_library(cfunc_filterfp16 LANGUAGE python SOURCES cfunc_filterfp16.i cfunc_filter.cu)
swig_link_libraries(cfunc_filterfp16 cudart cufft Python::Module)
set_target_properties(cfunc_filterfp16 PROPERTIES CUDA_ARCHITECTURES "60;72;75;80")
set_target_properties(cfunc_filterfp16 PROPERTIES CUDA_ARCHITECTURES "75;80")
target_compile_definitions(cfunc_filterfp16 PRIVATE HALF)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cfunc_filterfp16.py" DESTINATION tomocupy)
install(TARGETS cfunc_filterfp16 LIBRARY DESTINATION tomocupy)
Expand All @@ -81,22 +81,22 @@ install(TARGETS cfunc_filterfp16 LIBRARY DESTINATION tomocupy)
set_source_files_properties(cfunc_usfft1d.i PROPERTIES CPLUSPLUS ON)
swig_add_library(cfunc_usfft1d LANGUAGE python SOURCES cfunc_usfft1d.i cfunc_usfft1d.cu)
swig_link_libraries(cfunc_usfft1d cudart cufft Python::Module)
set_target_properties(cfunc_usfft1d PROPERTIES CUDA_ARCHITECTURES "60;72;75;80")
set_target_properties(cfunc_usfft1d PROPERTIES CUDA_ARCHITECTURES "75;80")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cfunc_usfft1d.py" DESTINATION tomocupy)
install(TARGETS cfunc_usfft1d LIBRARY DESTINATION tomocupy)

# Must tell CMake that SWIG interface files are CXX files
set_source_files_properties(cfunc_usfft2d.i PROPERTIES CPLUSPLUS ON)
swig_add_library(cfunc_usfft2d LANGUAGE python SOURCES cfunc_usfft2d.i cfunc_usfft2d.cu)
swig_link_libraries(cfunc_usfft2d cudart cufft Python::Module)
set_target_properties(cfunc_usfft2d PROPERTIES CUDA_ARCHITECTURES "60;72;75;80")
set_target_properties(cfunc_usfft2d PROPERTIES CUDA_ARCHITECTURES "75;80")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cfunc_usfft2d.py" DESTINATION tomocupy)
install(TARGETS cfunc_usfft2d LIBRARY DESTINATION tomocupy)

# Must tell CMake that SWIG interface files are CXX files
set_source_files_properties(cfunc_fft2d.i PROPERTIES CPLUSPLUS ON)
swig_add_library(cfunc_fft2d LANGUAGE python SOURCES cfunc_fft2d.i cfunc_fft2d.cu)
swig_link_libraries(cfunc_fft2d cudart cufft Python::Module)
set_target_properties(cfunc_fft2d PROPERTIES CUDA_ARCHITECTURES "60;72;75;80")
set_target_properties(cfunc_fft2d PROPERTIES CUDA_ARCHITECTURES "75;80")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cfunc_fft2d.py" DESTINATION tomocupy)
install(TARGETS cfunc_fft2d LIBRARY DESTINATION tomocupy)
76 changes: 56 additions & 20 deletions src/tomocupy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def default_parameter(func, param):
'default': 'none',
'type': str,
'help': "Phase retrieval correction method",
'choices': ['none', 'paganin', 'Gpaganin']},
'choices': ['none', 'paganin', 'Gpaganin', 'FourierFilter', 'farago']},
'energy': {
'default': 0,
'type': float,
Expand All @@ -240,7 +240,7 @@ def default_parameter(func, param):
'retrieve-phase-delta-beta': {
'default': 1500.0,
'type': float,
'help': "delta/beta material for Generalized Paganin"},
'help': "delta/beta material for Generalized Paganin & Farago"},
'retrieve-phase-W': {
'default': 2e-4,
'type': float,
Expand All @@ -249,6 +249,22 @@ def default_parameter(func, param):
'type': utils.positive_int,
'default': 1,
'help': "Padding with extra slices in z for phase-retrieval filtering"},
'FFratio': {
'default': 100,
'type': float,
'help': "Shape of the Fourier Filter window"},
'FFdim': {
'default': 2,
'type': float,
'help': "1 for sinograms, 2 for projections"},
'FFlog': {
'default': 0,
'type': int,
'help': "0/1"},
'FFpad': {
'default': 150,
'type': float,
'help': "Padding size for the Fourier Filter"},
}

SECTIONS['rotate-proj'] = {
Expand Down Expand Up @@ -395,21 +411,6 @@ def default_parameter(func, param):
'type': int,
'default': -1,
'help': "End row to find the rotation center"},
'dtype': {
'default': 'float32',
'type': str,
'choices': ['float32', 'float16'],
'help': "Data type used for reconstruction. Note float16 works with power of 2 sizes.", },
'save-format': {
'default': 'tiff',
'type': str,
'help': "Output format",
'choices': ['tiff', 'h5', 'h5sino', 'h5nolinks']},
'clear-folder': {
'default': 'False',
'type': str,
'help': "Clear output folder before reconstruction",
'choices': ['True', 'False']},
'fbp-filter': {
'default': 'parzen',
'type': str,
Expand Down Expand Up @@ -446,6 +447,41 @@ def default_parameter(func, param):
'type': float,
'help': "Pixel size [microns]"},
}
SECTIONS['output'] ={
'dtype': {
'default': 'float32',
'type': str,
'choices': ['float32', 'float16'],
'help': "Data type used for reconstruction. Note float16 works with power of 2 sizes.", },
'save-format': {
'default': 'tiff',
'type': str,
'help': "Output format",
'choices': ['tiff', 'h5', 'h5sino', 'h5nolinks', 'zarr']},
'zarr-compression': {
'default': 'blosclz',
'type': str,
'help': "ZARR compression format",
'choices': ['blosclz', 'lz4', 'zstd']},
'zarr-chunk': {
'default': '8,64,64',
'type': str,
'help': "ZARR chunk size"},
'large-data': {
'default': False,
'type': bool,
'help': "If Active it computes ldchunk chunks of angular projections"},
'ldchunk': {
'default': 10,
'type': int,
'help': "Number of angular chunks for large-data"},
'clear-folder': {
'default': 'False',
'type': str,
'help': "Clear output folder before reconstruction",
'choices': ['True', 'False']}
}


SECTIONS['beam-hardening'] = {
'beam-hardening-method': {
Expand Down Expand Up @@ -564,9 +600,9 @@ def default_parameter(func, param):


RECON_PARAMS = ('file-reading', 'remove-stripe',
'reconstruction', 'fw', 'ti', 'vo-all', 'lamino', 'reconstruction-types', 'beam-hardening')
'reconstruction', 'fw', 'ti', 'vo-all', 'lamino', 'reconstruction-types', 'beam-hardening', 'output')
RECON_STEPS_PARAMS = ('file-reading', 'remove-stripe', 'reconstruction',
'retrieve-phase', 'fw', 'ti', 'vo-all', 'lamino', 'reconstruction-steps-types', 'rotate-proj', 'beam-hardening')
'retrieve-phase', 'fw', 'ti', 'vo-all', 'lamino', 'reconstruction-steps-types', 'rotate-proj', 'beam-hardening', 'output')

NICE_NAMES = ('General', 'File reading', 'Remove stripe',
'Remove stripe FW', 'Remove stripe Titarenko', 'Remove stripe Vo' 'Retrieve phase', 'Reconstruction')
Expand Down Expand Up @@ -773,7 +809,7 @@ def update_hdf_process(fname, args=None, sections=None):
hdf_file.require_dataset(dataset, shape=(1,), dtype=dt)
log.info(name + ': ' + str(value))
try:
hdf_file[dataset][0] = np.string_(str(value))
hdf_file[dataset][0] = np.bytes_(str(value))
except TypeError:
log.error(
"Could not convert value {}".format(value))
Expand Down
11 changes: 7 additions & 4 deletions src/tomocupy/dataio/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def init_sizes(self):

# read data sizes and projection angles with a reader
sizes = self.read_sizes()
theta = self.read_theta()
theta = self.read_theta(sizes['nproji'])
nproji = sizes['nproji']
nzi = sizes['nzi']
ni = sizes['ni']
Expand Down Expand Up @@ -306,12 +306,15 @@ def read_sizes(self):

return sizes

def read_theta(self):
def read_theta(self, projections):
"""Read projection angles (in radians)"""

with h5py.File(args.file_name) as file_in:
theta = file_in['/exchange/theta'][:].astype('float32')/180*np.pi

if '/exchange/theta' in file_in:
theta = file_in['/exchange/theta'][:].astype('float32') / 180 * np.pi
else:
# If 'theta' doesn't exist, calculate it over the range [0, proj]
theta = np.linspace(0, np.pi, projections, dtype='float32')
return theta

def read_data_chunk_to_queue(self, data_queue, ids_proj, st_z, end_z, st_n, end_n, id_z, in_dtype):
Expand Down
Loading