From 2cc4ae2b8f0ed5923a4bfa5c5e048c310daabdca Mon Sep 17 00:00:00 2001 From: Benjamin Aron Date: Mon, 17 Jun 2024 19:21:44 -0400 Subject: [PATCH] fixed seed during SMI, read input .bshape/.echotime files, drop progress bars, github actions again --- .github/workflows/build_wheels.yml | 29 +++--- lib/designer_func_wrappers.py | 140 ++++++++++++++++++++++++++--- lib/designer_input_utils.py | 33 ++++++- lib/mpcomplex.py | 3 +- lib/mpdenoise_adaptive.py | 3 +- lib/smi.py | 27 +++--- rpg_cpp/fftw-3.3.10/config.log | 42 ++++----- rpg_cpp/unring_rpg_pybind.cpp | 15 +--- 8 files changed, 215 insertions(+), 77 deletions(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 55fadb7a..0c4344a7 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -39,8 +39,11 @@ jobs: fi done " + - name: Verify wheels + run: | + ls -al dist/ - name: Upload to PyPI - uses: pypa/gh-action-pypi-publish@master + uses: pypa/gh-action-pypi-publish@release/v1 with: repository_url: https://upload.pypi.org/legacy/ username: __token__ @@ -79,8 +82,11 @@ jobs: delocate-listdeps dist/*.whl # lists library dependencies delocate-wheel dist/*.whl # copies library dependencies into the wheel fi + - name: Verify wheels + run: | + ls -al dist/ - name: Upload to PyPI - uses: pypa/gh-action-pypi-publish@master + uses: pypa/gh-action-pypi-publish@release/v1 with: repository_url: https://upload.pypi.org/legacy/ username: __token__ @@ -100,24 +106,17 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip setuptools wheel pybind11 - - name: Download and install FFTW + - name: Install FFTW run: | - curl -L -o fftw.zip http://www.fftw.org/fftw-3.3.10-dll64.zip - if (-not (Test-Path fftw.zip)) { - Write-Error "Failed to download fftw.zip" - exit 1 - } - Expand-Archive fftw.zip -DestinationPath fftw - if (-not (Test-Path fftw)) { - Write-Error "Failed to unzip fftw.zip" - exit 1 - } - copy fftw/*.dll C:\Windows\System32 + conda install -c conda-forge fftw - name: Build wheels run: | python setup.py bdist_wheel + - name: Verify wheels + run: | + ls -al dist/ - name: Upload to PyPI - uses: pypa/gh-action-pypi-publish@master + uses: pypa/gh-action-pypi-publish@release/v1 with: repository_url: https://upload.pypi.org/legacy/ username: __token__ diff --git a/lib/designer_func_wrappers.py b/lib/designer_func_wrappers.py index 0441410f..6961713c 100644 --- a/lib/designer_func_wrappers.py +++ b/lib/designer_func_wrappers.py @@ -17,6 +17,9 @@ run_normalization: """ +import time +import shutil + def run_mppca(args_extent, args_phase, args_shrinkage, args_algorithm): """ wrapper for complex or magnitude, adatpive or local mppca @@ -45,7 +48,13 @@ def run_mppca(args_extent, args_phase, args_shrinkage, args_algorithm): # note adaptive patch does not include mpcomplex n_cores = app.ARGS.n_cores + terminal_width = shutil.get_terminal_size().columns + separator = "=" * terminal_width + + print("\n" + separator) print('...denoising...') + start_time = time.time() + if app.ARGS.adaptive_patch: Signal, Sigma, Nparameters = mp.denoise( dwi, phase=args_phase, patchtype='nonlocal', shrinkage=args_shrinkage, algorithm=args_algorithm @@ -75,6 +84,17 @@ def run_mppca(args_extent, args_phase, args_shrinkage, args_algorithm): #run.command('dwidenoise -noise fullnoisemap.mif -estimator Exp2 working.mif dwidn.mif') run.command('mrconvert -force dwidn.mif working.mif', show=False) + # End timer + end_time = time.time() + elapsed_time = end_time - start_time + + # Convert elapsed time to hours and minutes + hours, rem = divmod(elapsed_time, 3600) + minutes, seconds = divmod(rem, 60) + + print(f"Denoising completed in {int(hours):02} hours, {int(minutes):02} minutes, {int(seconds):02} seconds.") + print(separator + "\n") + def run_patch2self(): """ wrapper for patch2self @@ -84,6 +104,13 @@ def run_patch2self(): from ants import image_read, image_write, from_numpy import numpy as np + terminal_width = shutil.get_terminal_size().columns + separator = "=" * terminal_width + + print("\n" + separator) + print('...denoising...') + start_time = time.time() + run.command('mrconvert -force -export_grad_fsl working.bvec working.bval working.mif working.nii', show=False) nii = image_read('working.nii') dwi = nii.numpy() @@ -95,6 +122,16 @@ def run_patch2self(): image_write(out, 'working_p2s.nii') run.command('mrconvert -force -fslgrad working.bvec working.bval working_p2s.nii working.mif', show=False) + # End timer + end_time = time.time() + elapsed_time = end_time - start_time + + # Convert elapsed time to hours and minutes + hours, rem = divmod(elapsed_time, 3600) + minutes, seconds = divmod(rem, 60) + + print(f"Denoising completed in {int(hours):02} hours, {int(minutes):02} minutes, {int(seconds):02} seconds.") + print(separator + "\n") def run_degibbs(pf, pe_dir): """ @@ -104,7 +141,7 @@ def run_degibbs(pf, pe_dir): import lib.rpg as rpg from mrtrix3 import run, app, MRtrixError from ants import image_read, image_write, from_numpy - from tqdm import tqdm + # from tqdm import tqdm # import os # rpg_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),'rpg_cpp') @@ -113,7 +150,13 @@ def run_degibbs(pf, pe_dir): run.command('mrconvert -force -export_grad_fsl working.bvec working.bval working.mif working.nii', show=False) nii = image_read('working.nii') dwi = nii.numpy() - print("...RPG degibbsing...") + + terminal_width = shutil.get_terminal_size().columns + separator = "=" * terminal_width + + print("\n" + separator) + print('...RPG degibbsing...') + start_time = time.time() n_cores = app.ARGS.n_cores @@ -131,13 +174,13 @@ def run_degibbs(pf, pe_dir): pe_dir = 1 dwi_t = dwi.transpose(3,2,1,0) - progress_bar = tqdm(total=100) - def progress_callback(progress): - progress_bar.n = progress - progress_bar.refresh() + #progress_bar = tqdm(total=100) + #def progress_callback(progress): + # progress_bar.n = progress + # progress_bar.refresh() - dwi_dg_t = rpg.unring(dwi_t, minW=1, maxW=3, nsh=20, pfv=float(pf), pfdimf=pe_dir, phase_flag=False, progress_callback=progress_callback) - progress_bar.close() + dwi_dg_t = rpg.unring(dwi_t, minW=1, maxW=3, nsh=20, pfv=float(pf), pfdimf=pe_dir, phase_flag=False) + #progress_bar.close() dwi_dg = dwi_dg_t[0].copy().transpose(3,2,1,0) out = from_numpy( @@ -147,6 +190,16 @@ def progress_callback(progress): #convert gibbs corrected nii to .mif run.command('mrconvert -force -fslgrad working.bvec working.bval working_rpg.nii working.mif', show=False) + # End timer + end_time = time.time() + elapsed_time = end_time - start_time + + # Convert elapsed time to hours and minutes + hours, rem = divmod(elapsed_time, 3600) + minutes, seconds = divmod(rem, 60) + + print(f"RPG gibbs correction completed in {int(hours):02} hours, {int(minutes):02} minutes, {int(seconds):02} seconds.") + print(separator + "\n") def group_alignment(group_list): from mrtrix3 import app, run, path, image, fsl, MRtrixError @@ -154,7 +207,12 @@ def group_alignment(group_list): fsl_suffix = fsl.suffix() + terminal_width = shutil.get_terminal_size().columns + separator = "=" * terminal_width + + print("\n" + separator) print('... Rigidly aligning groups...') + start_time = time.time() # 1) find the longest series and extract the b0 group_len = [] @@ -218,6 +276,17 @@ def group_alignment(group_list): show=False) run.command('mrconvert -force dwi_align_series_aligned.mif working.mif', show=False) + # End timer + end_time = time.time() + elapsed_time = end_time - start_time + + # Convert elapsed time to hours and minutes + hours, rem = divmod(elapsed_time, 3600) + minutes, seconds = divmod(rem, 60) + + print(f"rigid alignment completed in {int(hours):02} hours, {int(minutes):02} minutes, {int(seconds):02} seconds.") + print(separator + "\n") + def convert_ants_xform(mat, i): import scipy.io as sio @@ -242,6 +311,13 @@ def pre_eddy_ants_moco(dwi_metadata): import ants from mrtrix3 import app, run, path, image, fsl, MRtrixError import numpy as np + + terminal_width = shutil.get_terminal_size().columns + separator = "=" * terminal_width + + print("\n" + separator) + print('... ANTS motion correction...') + start_time = time.time() run.command('mrconvert -force -export_grad_fsl working.bvec working.bval working.mif working.nii', show=False) nii = ants.image_read('working.nii') @@ -280,6 +356,17 @@ def pre_eddy_ants_moco(dwi_metadata): np.savetxt('working_antsmoco.bvec', dirs_rot.T, delimiter=' ', fmt='%4.10f') run.command('mrconvert -force -fslgrad working_antsmoco.bvec working.bval working_antsmoco.nii working.mif', show=False) + # End timer + end_time = time.time() + elapsed_time = end_time - start_time + + # Convert elapsed time to hours and minutes + hours, rem = divmod(elapsed_time, 3600) + minutes, seconds = divmod(rem, 60) + + print(f"motion correction completed in {int(hours):02} hours, {int(minutes):02} minutes, {int(seconds):02} seconds.") + print(separator + "\n") + def run_pre_align(dwi_metadata): from mrtrix3 import app, run, path, image, fsl, MRtrixError @@ -308,7 +395,13 @@ def run_eddy(shell_table, dwi_metadata): import os import glob - print("...Eddy current, EPI, motion correction...") + terminal_width = shutil.get_terminal_size().columns + separator = "=" * terminal_width + + print("\n" + separator) + print('... Eddy current, EPI, motion correction...') + start_time = time.time() + run.command('mrconvert -force -export_grad_fsl working.bvec working.bval working.mif working.nii', show=False) eddyopts = '" --cnr_maps --repol --data_is_shelled "' @@ -733,6 +826,16 @@ def run_eddy(shell_table, dwi_metadata): raise MRtrixError("the eddy option must run alongside -rpe_header, -rpe_all, or -rpe_pair option") run.command('mrconvert -force -fslgrad working.bvec working.bval dwiec.mif working.mif', show=False) + # End timer + end_time = time.time() + elapsed_time = end_time - start_time + + # Convert elapsed time to hours and minutes + hours, rem = divmod(elapsed_time, 3600) + minutes, seconds = divmod(rem, 60) + + print(f"Eddy current, EPI, motion correction completed in {int(hours):02} hours, {int(minutes):02} minutes, {int(seconds):02} seconds.") + print(separator + "\n") def run_b1correct(dwi_metadata): from mrtrix3 import run @@ -740,8 +843,14 @@ def run_b1correct(dwi_metadata): DWInlist = dwi_metadata['dwi_list'] idxlist = dwi_metadata['idxlist'] + terminal_width = shutil.get_terminal_size().columns + separator = "=" * terminal_width + + print("\n" + separator) + print('... B1 correction...') + start_time = time.time() + # b1 bias field correction - print("...B1 correction...") if len(DWInlist) == 1: run.command('dwibiascorrect ants -bias biasfield.mif working.mif dwibc.mif') else: @@ -759,6 +868,17 @@ def run_b1correct(dwi_metadata): run.command('mrcat -axis 3 ' + DWImif + ' dwibc.mif') run.command('mrconvert -force dwibc.mif working.mif', show=False) + # End timer + end_time = time.time() + elapsed_time = end_time - start_time + + # Convert elapsed time to hours and minutes + hours, rem = divmod(elapsed_time, 3600) + minutes, seconds = divmod(rem, 60) + + print(f"Eddy current, EPI, motion correction completed in {int(hours):02} hours, {int(minutes):02} minutes, {int(seconds):02} seconds.") + print(separator + "\n") + def create_brainmask(fsl_suffix): import os, gzip, shutil from mrtrix3 import run diff --git a/lib/designer_input_utils.py b/lib/designer_input_utils.py index b9ba6fa3..a4954fb8 100644 --- a/lib/designer_input_utils.py +++ b/lib/designer_input_utils.py @@ -68,6 +68,21 @@ def get_input_info(input, fslbval, fslbvec, bids): UserBidspath = bids.resplit(',') bidslist = [os.path.realpath(i) for i in UserBidspath] + bshapelist = [i + '.bshape' for i in DWInlist] + telist = [i + '.echotime' for i in DWInlist] + try: + for i in bshapelist: + if not os.path.exists(i): + bshapelist = None + break + for i in telist: + if not os.path.exists(i): + telist = None + break + except: + bshapelist = None + telist = None + # if the user provides the path to phases try: phase_cpath = app.ARGS.phase.rsplit(',') @@ -87,7 +102,10 @@ def get_input_info(input, fslbval, fslbvec, bids): 'dwi_list': DWInlist, 'phase_list': phase_nlist, 'phase_ext': phase_ext, - 'bidslist': bidslist} + 'bidslist': bidslist, + 'bshapelist': bshapelist, + 'telist': telist + } return dwi_metadata @@ -205,6 +223,10 @@ def assert_inputs(dwi_metadata, args_pe_dir, args_pf): else: TE = TE_app + #if TE is not None: + if (len(set(TE)) > 1) and (not app.ARGS.rpe_te): + raise MRtrixError('If data has variable echo time and no RPE TE is specified, please use the -rpe_te flag to specify the RPE TE') + # if no partial fourier information is found, assume full sampling if not args_pf and not pf_bids: args_pf = 1 @@ -268,6 +290,8 @@ def convert_input_data(dwi_metadata): bshape_per_series = dwi_metadata['bshape'] phase_n_list = dwi_metadata['phase_list'] phase_ext = dwi_metadata['phase_ext'] + bshapelist_input = dwi_metadata['bshapelist'] + telist_input = dwi_metadata['telist'] if len(dwi_n_list) == 1: if not isdicom: @@ -312,7 +336,7 @@ def convert_input_data(dwi_metadata): DWImif = ' '.join(miflist) cmd = ('mrcat -axis 3 %s %s/dwi.mif' % (DWImif, app.SCRATCH_DIR)) run.command(cmd) - + try: if phase_n_list: if len(phase_n_list) == 1: @@ -356,6 +380,11 @@ def convert_input_data(dwi_metadata): telist = [item for sublist in telist for item in sublist] bshapelist = [item for sublist in bshapelist for item in sublist] + if telist_input is not None: + telist = np.hstack([np.loadtxt(i) for i in telist_input]) + if bshapelist_input is not None: + bshapelist = np.hstack([np.loadtxt(i) for i in bshapelist_input]) + dwi_metadata['idxlist'] = idxlist dwi_metadata['echo_time_per_volume'] = np.array(telist) dwi_metadata['bshape_per_volume'] = np.array(bshapelist) diff --git a/lib/mpcomplex.py b/lib/mpcomplex.py index 5cecd53c..09bad0f6 100644 --- a/lib/mpcomplex.py +++ b/lib/mpcomplex.py @@ -248,7 +248,6 @@ def im_reconstruct(self, wp, image): def process(self): from joblib import Parallel, delayed - from tqdm import tqdm num_patches = self.temp.shape[0] num_vols = self.dwi.shape[1] @@ -260,7 +259,7 @@ def process(self): results = Parallel(n_jobs=self.n_cores, prefer='processes')\ - (delayed(self.denoise)(self.dwi[self.temp[i,:],:]) for i in tqdm(range(num_patches))) + (delayed(self.denoise)(self.dwi[self.temp[i,:],:]) for i in range(num_patches)) signal, sigma, npars = zip(*results) diff --git a/lib/mpdenoise_adaptive.py b/lib/mpdenoise_adaptive.py index b2ee5fe7..d06eba7d 100644 --- a/lib/mpdenoise_adaptive.py +++ b/lib/mpdenoise_adaptive.py @@ -53,7 +53,6 @@ import numpy as np import multiprocessing from joblib import Parallel, delayed -from tqdm import tqdm import scipy.linalg import warnings @@ -347,7 +346,7 @@ def process(self): xsize = int(x.size) coords = np.vstack((x,y,z)) - inputs = tqdm(range(0, xsize)) + inputs = range(0, xsize) num_cores = multiprocessing.cpu_count() # # parallel diff --git a/lib/smi.py b/lib/smi.py index dce29c26..811cfe34 100644 --- a/lib/smi.py +++ b/lib/smi.py @@ -20,8 +20,8 @@ class SMI(object): def __init__(self, bval, bvec, beta=None, echo_time=None, merge_distance=None, cs_phase=1, flag_fit_fodf=0, flag_rectify_fodf=0, compartments=None, n_levels=10, l_max=None, rotinv_lmax=None, - noise_bias=None, training_bounds=None, training_prior=None, n_training=1e5, - l_max_training = None): + noise_bias=None, training_bounds=None, training_prior=None, n_training=5e5, + l_max_training = None, seed=42): """ Setting some default values and initialization required for class functions """ @@ -69,6 +69,9 @@ def __init__(self, bval, bvec, beta=None, echo_time=None, merge_distance=None, c elif noise_bias == 'rician': self.flag_rician_bias = True + if seed is not None: + self.seed = seed + # set up required inputs self.set_bvals_bvecs(bval, bvec) self.set_bshape(beta) @@ -128,10 +131,13 @@ def set_bshape(self, beta): else: self.beta = beta - if self.flag_microstructure_units: - self.beta[self.b < 0.05] = 1 - else: - self.beta[self.b < 50] = 1 + try: + if self.flag_microstructure_units: + self.beta[self.b < 0.05] = 1 + else: + self.beta[self.b < 50] = 1 + except: + raise Exception('something wrong with input bshapes, check input data') if not self.merge_distance: if self.flag_microstructure_units: @@ -1006,6 +1012,9 @@ def standard_model_mlfit_rot_invs(self, rot_invs, sigma_norm_limits): rotinvs_train_norm = rotinvs_train / rotinvs_train[:,[0]] + if self.seed is not None: + np.random.seed(self.seed) + for i in range(1, len(sigma_noise_norm_levels_edges)): flag_current_noise_level = (sigma_noise_norm_levels_ids == i) @@ -1016,12 +1025,6 @@ def standard_model_mlfit_rot_invs(self, rot_invs, sigma_norm_limits): meas_rotinvs_train = (rotinvs_train_norm + sigma_rotinvs_training * np.random.standard_normal(size=rotinvs_train_norm.shape) ) - #import scipy.io as sio - #seedmat = sio.loadmat('/Users/benaron/Desktop/subj_1/randomseed.mat') - #seedsigma = seedmat['randomseed'] - #meas_rotinvs_train = (rotinvs_train_norm + - # sigma_rotinvs_training * seedsigma) - # import pdb; pdb.set_trace() x_train = self.compute_extended_moments( meas_rotinvs_train[:, keep_rot_invs_kernel], degree=degree_kernel) diff --git a/rpg_cpp/fftw-3.3.10/config.log b/rpg_cpp/fftw-3.3.10/config.log index b9b2f677..c15c173d 100644 --- a/rpg_cpp/fftw-3.3.10/config.log +++ b/rpg_cpp/fftw-3.3.10/config.log @@ -30,14 +30,14 @@ Kernel configured for up to 10 processors. Processor type: arm64e (ARM64E) Processors active: 0 1 2 3 4 5 6 7 8 9 Primary memory available: 64.00 gigabytes -Default processor set: 763 tasks, 5188 threads, 10 processors -Load average: 13.04, Mach factor: 0.69 +Default processor set: 947 tasks, 5417 threads, 10 processors +Load average: 4.41, Mach factor: 6.13 /bin/machine = unknown /usr/bin/oslevel = unknown /bin/universe = unknown -PATH: /private/var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T/pip-build-env-ij2t3_ru/overlay/bin -PATH: /private/var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T/pip-build-env-ij2t3_ru/normal/bin +PATH: /private/var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T/pip-build-env-jqv3upp5/overlay/bin +PATH: /private/var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T/pip-build-env-jqv3upp5/normal/bin PATH: /Users/benaron/.rbenv/shims PATH: /opt/homebrew/Caskroom/miniforge/base/envs/rpgenv/bin PATH: /opt/homebrew/Caskroom/miniforge/base/condabin @@ -1361,7 +1361,7 @@ configure:16901: checking for _doprnt configure:16901: gcc -o conftest -fPIC conftest.c >&5 ld: Undefined symbols: __doprnt, referenced from: - _main in conftest-e11682.o + _main in conftest-67e6bd.o clang: error: linker command failed with exit code 1 (use -v to see invocation) configure:16901: $? = 1 configure: failed program was: @@ -1464,7 +1464,7 @@ configure:17051: checking for BSDgettimeofday configure:17051: gcc -o conftest -fPIC conftest.c -lm >&5 ld: Undefined symbols: _BSDgettimeofday, referenced from: - _main in conftest-f9c4cf.o + _main in conftest-050a84.o clang: error: linker command failed with exit code 1 (use -v to see invocation) configure:17051: $? = 1 configure: failed program was: @@ -1563,7 +1563,7 @@ configure:17051: checking for gethrtime configure:17051: gcc -o conftest -fPIC conftest.c -lm >&5 ld: Undefined symbols: _gethrtime, referenced from: - _main in conftest-558be8.o + _main in conftest-692dbd.o clang: error: linker command failed with exit code 1 (use -v to see invocation) configure:17051: $? = 1 configure: failed program was: @@ -1659,7 +1659,7 @@ configure:17051: checking for read_real_time configure:17051: gcc -o conftest -fPIC conftest.c -lm >&5 ld: Undefined symbols: _read_real_time, referenced from: - _main in conftest-ae394d.o + _main in conftest-018434.o clang: error: linker command failed with exit code 1 (use -v to see invocation) configure:17051: $? = 1 configure: failed program was: @@ -1755,7 +1755,7 @@ configure:17051: checking for time_base_to_time configure:17051: gcc -o conftest -fPIC conftest.c -lm >&5 ld: Undefined symbols: _time_base_to_time, referenced from: - _main in conftest-04a9a7.o + _main in conftest-369820.o clang: error: linker command failed with exit code 1 (use -v to see invocation) configure:17051: $? = 1 configure: failed program was: @@ -1882,7 +1882,7 @@ conftest.c:77:6: note: 'memalign' is a builtin with type 'void *(unsigned long, 1 warning generated. ld: Undefined symbols: _memalign, referenced from: - _main in conftest-db632b.o + _main in conftest-8ceee6.o clang: error: linker command failed with exit code 1 (use -v to see invocation) configure:17051: $? = 1 configure: failed program was: @@ -1982,7 +1982,7 @@ configure:17051: checking for _mm_malloc configure:17051: gcc -o conftest -fPIC conftest.c -lm >&5 ld: Undefined symbols: __mm_malloc, referenced from: - _main in conftest-b57cad.o + _main in conftest-e128c6.o clang: error: linker command failed with exit code 1 (use -v to see invocation) configure:17051: $? = 1 configure: failed program was: @@ -2082,7 +2082,7 @@ configure:17051: checking for _mm_free configure:17051: gcc -o conftest -fPIC conftest.c -lm >&5 ld: Undefined symbols: __mm_free, referenced from: - _main in conftest-eba22f.o + _main in conftest-0377e7.o clang: error: linker command failed with exit code 1 (use -v to see invocation) configure:17051: $? = 1 configure: failed program was: @@ -2831,22 +2831,22 @@ Target: aarch64-apple-darwin23 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 13.2.0 (Homebrew GCC 13.2.0) - /opt/homebrew/Cellar/gcc/13.2.0/bin/../libexec/gcc/aarch64-apple-darwin23/13/f951 conftest.f -ffixed-form -fPIC -quiet -dumpbase conftest.f -dumpbase-ext .f -mmacosx-version-min=14.0.0 -mlittle-endian -mabi=lp64 -g -O2 -version -fintrinsic-modules-path /opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/13/finclude -o /var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T//ccPLcmXd.s + /opt/homebrew/Cellar/gcc/13.2.0/bin/../libexec/gcc/aarch64-apple-darwin23/13/f951 conftest.f -ffixed-form -fPIC -quiet -dumpbase conftest.f -dumpbase-ext .f -mmacosx-version-min=14.0.0 -mlittle-endian -mabi=lp64 -g -O2 -version -fintrinsic-modules-path /opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/13/finclude -o /var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T//cc4POEET.s GNU Fortran (Homebrew GCC 13.2.0) version 13.2.0 (aarch64-apple-darwin23) compiled by GNU C version 13.2.0, GMP version 6.2.1, MPFR version 4.2.0-p12, MPC version 1.3.1, isl version isl-0.26-GMP warning: GMP header version 6.2.1 differs from library version 6.3.0. warning: MPFR header version 4.2.0-p12 differs from library version 4.2.1. GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 - as -arch arm64 -v -mmacosx-version-min=14.0 -o /var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T//ccoYkpj1.o /var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T//ccPLcmXd.s + as -arch arm64 -v -mmacosx-version-min=14.0 -o /var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T//ccl1j6d1.o /var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T//cc4POEET.s Apple clang version 15.0.0 (clang-1500.0.40.1) Target: arm64-apple-darwin23.0.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin - "/Library/Developer/CommandLineTools/usr/bin/clang" -cc1as -triple arm64-apple-macosx14.0.0 -filetype obj -main-file-name ccPLcmXd.s -target-cpu apple-m1 -target-feature +v8.5a -target-feature +crc -target-feature +lse -target-feature +rdm -target-feature +crypto -target-feature +dotprod -target-feature +fp-armv8 -target-feature +neon -target-feature +fp16fml -target-feature +ras -target-feature +rcpc -target-feature +zcm -target-feature +zcz -target-feature +fullfp16 -target-feature +sm4 -target-feature +sha3 -target-feature +sha2 -target-feature +aes -fdebug-compilation-dir=/Users/benaron/Documents/designer_v2_dev/rpg_cpp/fftw-3.3.10 -dwarf-debug-producer "Apple clang version 15.0.0 (clang-1500.0.40.1)" -dwarf-version=4 -mrelocation-model pic --mrelax-relocations -mllvm -disable-aligned-alloc-awareness=1 -o /var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T//ccoYkpj1.o /var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T//ccPLcmXd.s + "/Library/Developer/CommandLineTools/usr/bin/clang" -cc1as -triple arm64-apple-macosx14.0.0 -filetype obj -main-file-name cc4POEET.s -target-cpu apple-m1 -target-feature +v8.5a -target-feature +crc -target-feature +lse -target-feature +rdm -target-feature +crypto -target-feature +dotprod -target-feature +fp-armv8 -target-feature +neon -target-feature +fp16fml -target-feature +ras -target-feature +rcpc -target-feature +zcm -target-feature +zcz -target-feature +fullfp16 -target-feature +sm4 -target-feature +sha3 -target-feature +sha2 -target-feature +aes -fdebug-compilation-dir=/Users/benaron/Documents/designer_v2_dev/rpg_cpp/fftw-3.3.10 -dwarf-debug-producer "Apple clang version 15.0.0 (clang-1500.0.40.1)" -dwarf-version=4 -mrelocation-model pic --mrelax-relocations -mllvm -disable-aligned-alloc-awareness=1 -o /var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T//ccl1j6d1.o /var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T//cc4POEET.s Reading specs from /opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/13/../../../libgfortran.spec rename spec lib to liborig - /opt/homebrew/Cellar/gcc/13.2.0/bin/../libexec/gcc/aarch64-apple-darwin23/13/collect2 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/ -dynamic -arch arm64 -platform_version macos 14.0.0 0.0 -o conftest -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/13 -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/13/../../.. /var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T//ccoYkpj1.o -lgfortran -lemutls_w -lgcc -lquadmath -lemutls_w -lgcc -lSystem -lgcc -no_compact_unwind -rpath @loader_path -rpath /opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc/aarch64-apple-darwin23/13 -rpath /opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc -rpath /opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current -idsym -dsym + /opt/homebrew/Cellar/gcc/13.2.0/bin/../libexec/gcc/aarch64-apple-darwin23/13/collect2 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/ -dynamic -arch arm64 -platform_version macos 14.0.0 0.0 -o conftest -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/13 -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/13/../../.. /var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T//ccl1j6d1.o -lgfortran -lemutls_w -lgcc -lquadmath -lemutls_w -lgcc -lSystem -lgcc -no_compact_unwind -rpath @loader_path -rpath /opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc/aarch64-apple-darwin23/13 -rpath /opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc -rpath /opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current -idsym -dsym configure:20762: result: -v configure:20764: checking for Fortran 77 libraries of gfortran configure:20787: gfortran -o conftest -g -O2 -v conftest.f -lm @@ -2855,22 +2855,22 @@ Target: aarch64-apple-darwin23 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 13.2.0 (Homebrew GCC 13.2.0) - /opt/homebrew/Cellar/gcc/13.2.0/bin/../libexec/gcc/aarch64-apple-darwin23/13/f951 conftest.f -ffixed-form -fPIC -quiet -dumpbase conftest.f -dumpbase-ext .f -mmacosx-version-min=14.0.0 -mlittle-endian -mabi=lp64 -g -O2 -version -fintrinsic-modules-path /opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/13/finclude -o /var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T//ccEGeAN6.s + /opt/homebrew/Cellar/gcc/13.2.0/bin/../libexec/gcc/aarch64-apple-darwin23/13/f951 conftest.f -ffixed-form -fPIC -quiet -dumpbase conftest.f -dumpbase-ext .f -mmacosx-version-min=14.0.0 -mlittle-endian -mabi=lp64 -g -O2 -version -fintrinsic-modules-path /opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/13/finclude -o /var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T//cczcUSyt.s GNU Fortran (Homebrew GCC 13.2.0) version 13.2.0 (aarch64-apple-darwin23) compiled by GNU C version 13.2.0, GMP version 6.2.1, MPFR version 4.2.0-p12, MPC version 1.3.1, isl version isl-0.26-GMP warning: GMP header version 6.2.1 differs from library version 6.3.0. warning: MPFR header version 4.2.0-p12 differs from library version 4.2.1. GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 - as -arch arm64 -v -mmacosx-version-min=14.0 -o /var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T//cc0VvUGK.o /var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T//ccEGeAN6.s + as -arch arm64 -v -mmacosx-version-min=14.0 -o /var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T//cc6EssT5.o /var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T//cczcUSyt.s Apple clang version 15.0.0 (clang-1500.0.40.1) Target: arm64-apple-darwin23.0.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin - "/Library/Developer/CommandLineTools/usr/bin/clang" -cc1as -triple arm64-apple-macosx14.0.0 -filetype obj -main-file-name ccEGeAN6.s -target-cpu apple-m1 -target-feature +v8.5a -target-feature +crc -target-feature +lse -target-feature +rdm -target-feature +crypto -target-feature +dotprod -target-feature +fp-armv8 -target-feature +neon -target-feature +fp16fml -target-feature +ras -target-feature +rcpc -target-feature +zcm -target-feature +zcz -target-feature +fullfp16 -target-feature +sm4 -target-feature +sha3 -target-feature +sha2 -target-feature +aes -fdebug-compilation-dir=/Users/benaron/Documents/designer_v2_dev/rpg_cpp/fftw-3.3.10 -dwarf-debug-producer "Apple clang version 15.0.0 (clang-1500.0.40.1)" -dwarf-version=4 -mrelocation-model pic --mrelax-relocations -mllvm -disable-aligned-alloc-awareness=1 -o /var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T//cc0VvUGK.o /var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T//ccEGeAN6.s + "/Library/Developer/CommandLineTools/usr/bin/clang" -cc1as -triple arm64-apple-macosx14.0.0 -filetype obj -main-file-name cczcUSyt.s -target-cpu apple-m1 -target-feature +v8.5a -target-feature +crc -target-feature +lse -target-feature +rdm -target-feature +crypto -target-feature +dotprod -target-feature +fp-armv8 -target-feature +neon -target-feature +fp16fml -target-feature +ras -target-feature +rcpc -target-feature +zcm -target-feature +zcz -target-feature +fullfp16 -target-feature +sm4 -target-feature +sha3 -target-feature +sha2 -target-feature +aes -fdebug-compilation-dir=/Users/benaron/Documents/designer_v2_dev/rpg_cpp/fftw-3.3.10 -dwarf-debug-producer "Apple clang version 15.0.0 (clang-1500.0.40.1)" -dwarf-version=4 -mrelocation-model pic --mrelax-relocations -mllvm -disable-aligned-alloc-awareness=1 -o /var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T//cc6EssT5.o /var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T//cczcUSyt.s Reading specs from /opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/13/../../../libgfortran.spec rename spec lib to liborig - /opt/homebrew/Cellar/gcc/13.2.0/bin/../libexec/gcc/aarch64-apple-darwin23/13/collect2 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/ -dynamic -arch arm64 -platform_version macos 14.0.0 0.0 -o conftest -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/13 -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/13/../../.. /var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T//cc0VvUGK.o -lgfortran -lemutls_w -lgcc -lquadmath -lemutls_w -lgcc -lSystem -lgcc -no_compact_unwind -rpath @loader_path -rpath /opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc/aarch64-apple-darwin23/13 -rpath /opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc -rpath /opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current -idsym -dsym + /opt/homebrew/Cellar/gcc/13.2.0/bin/../libexec/gcc/aarch64-apple-darwin23/13/collect2 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/ -dynamic -arch arm64 -platform_version macos 14.0.0 0.0 -o conftest -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/13 -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/13/../../.. /var/folders/85/2c_hpzlx3j50c40lxtpwq5300000gn/T//cc6EssT5.o -lgfortran -lemutls_w -lgcc -lquadmath -lemutls_w -lgcc -lSystem -lgcc -no_compact_unwind -rpath @loader_path -rpath /opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc/aarch64-apple-darwin23/13 -rpath /opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc -rpath /opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current -idsym -dsym configure:20983: result: -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/13 -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/13/../../.. -lgfortran -lemutls_w -lquadmath configure:20999: checking for dummy main to link with Fortran 77 libraries configure:21033: gcc -o conftest -fPIC conftest.c -lm -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/13 -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/13/../../.. -lgfortran -lemutls_w -lquadmath >&5 @@ -2882,7 +2882,7 @@ configure:21131: $? = 0 configure:21172: gcc -o conftest -fPIC conftest.c cfortran_test.o -lm -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/13 -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/13/../../.. -lgfortran -lemutls_w -lquadmath >&5 ld: Undefined symbols: _foobar, referenced from: - _main in conftest-53df66.o + _main in conftest-74deea.o clang: error: linker command failed with exit code 1 (use -v to see invocation) configure:21172: $? = 1 configure: failed program was: diff --git a/rpg_cpp/unring_rpg_pybind.cpp b/rpg_cpp/unring_rpg_pybind.cpp index 8431dae8..4ce5da4c 100644 --- a/rpg_cpp/unring_rpg_pybind.cpp +++ b/rpg_cpp/unring_rpg_pybind.cpp @@ -831,8 +831,7 @@ void UnringScale(double *I, double *Ii, unsigned int nx, unsigned int ny, unsign py::tuple unring(py::array_t data, py::array_t phase = py::array_t(), unsigned int minW = 1, unsigned int maxW = 3, unsigned int nsh = 20, - double pfv = 6.0 / 8.0, bool pfdimf = true, bool phase_flag = false, - const std::function& progress_callback = nullptr) { + double pfv = 6.0 / 8.0, bool pfdimf = true, bool phase_flag = false) { py::buffer_info data_info = data.request(); py::buffer_info phase_info = phase_flag ? phase.request() : py::buffer_info(); @@ -935,15 +934,6 @@ py::tuple unring(py::array_t data, py::array_t phase = py::array } else { // real Unring(slicesin[i], 0, slicesout[i], 0, dim_sz, 2, pfo, minW, maxW, nsh); } - - // Call the progress callback periodically - if (progress_callback && i % (nz * ndwi / 100) == 0) { - progress_callback(static_cast((100 * i) / (nz * ndwi))); - } - } - - if (progress_callback) { - progress_callback(100); } // Put slices into volume (real) @@ -976,6 +966,5 @@ PYBIND11_MODULE(rpg, m) { m.def("unring", &unring, "Process data with given parameters", py::arg("data"), py::arg("phase") = py::array_t(), py::arg("minW") = 1, py::arg("maxW") = 3, py::arg("nsh") = 20, - py::arg("pfv") = 6.0 / 8.0, py::arg("pfdimf") = true, py::arg("phase_flag") = false, - py::arg("progress_callback") = nullptr); + py::arg("pfv") = 6.0 / 8.0, py::arg("pfdimf") = true, py::arg("phase_flag") = false); } \ No newline at end of file