From 5115f4b9ab1560042a3d2ecf0c6a7ac442850069 Mon Sep 17 00:00:00 2001 From: Hugo Karas Date: Mon, 11 Nov 2024 12:46:34 +0100 Subject: [PATCH 1/2] Bug fix in calc_DEER_settings and calc_correction_factor --- autodeer/DEER_analysis.py | 5 ++++- autodeer/gui/main.py | 13 ++++++++----- autodeer/relaxation_autodeer.py | 8 +++++--- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/autodeer/DEER_analysis.py b/autodeer/DEER_analysis.py index 6622196..edcaded 100644 --- a/autodeer/DEER_analysis.py +++ b/autodeer/DEER_analysis.py @@ -1106,7 +1106,10 @@ def calc_DEER_settings(relaxation_data,mode='auto', target_time=2, raise ValueError("No signal at either optimal") # Select between five-pulse and four-pulse DEER - if (V_4p > V_5p * 0.9) or (tau1_5p < 1.5) or mode =='4pDEER': + if (tau2_4p >= 2*tau1_5p) and (V_4p > V_5p * 0.9): + mode = '4pDEER' + + if (tau1_5p < 1.5) or mode =='4pDEER': # Use four-pulse DEER deer_settings = { 'ExpType': '4pDEER', diff --git a/autodeer/gui/main.py b/autodeer/gui/main.py index db175f8..2582436 100644 --- a/autodeer/gui/main.py +++ b/autodeer/gui/main.py @@ -871,8 +871,11 @@ def initialise_deer_settings(self): if 'T2_relax' in self.current_results: relax_data['Tm'] = self.current_results['T2_relax'] if 'relax2D' in self.current_results: - relax_data['Ref2D'] = self.current_results['relax2D'] - + relax_data['Ref2D'] = self.current_results['relax2D'] + + #debug only, remove later + store_pickle(relax_data,os.path.join(self.data_folder,'relax_data.pkl')) + self.deer_settings = ad.calc_DEER_settings(relax_data,exp,self.aim_time,aim_SNR,self.waveform_precision) self.deer_settings['criteria'] = self.aim_MNR @@ -949,12 +952,12 @@ def update_tau_delays_figure(self, SNRs, MeasTimes, labels=None): axs.cla() # Only supports 5pDEER expand to 4pDEER CP_analysis = self.current_results['relax'] - ad.plot_optimal_tau(CP_analysis,SNRs,MeasTimes,MaxMeasTime=36, labels=['5pDEER'],fig=fig,axs=axs,cmap=[ad.primary_colors[0]]) + ad.plot_optimal_tau(CP_analysis,SNRs,MeasTimes,MaxMeasTime=36, labels=['5pDEER'],fig=fig,axs=axs,cmap=[ad.primary_colors[0]],corr_factor=self.correction_factor) if 'relax2D' in self.current_results: - ad.plot_optimal_tau(self.current_results['relax2D'],SNRs,MeasTimes,MaxMeasTime=36, labels=['4pDEER'],fig=fig,axs=axs,cmap=[ad.primary_colors[1]]) + ad.plot_optimal_tau(self.current_results['relax2D'],SNRs,MeasTimes,MaxMeasTime=36, labels=['4pDEER'],fig=fig,axs=axs,cmap=[ad.primary_colors[1]],corr_factor=self.correction_factor) elif 'T2_relax' in self.current_results: - ad.plot_optimal_tau(self.current_results['T2_relax'],SNRs,MeasTimes,MaxMeasTime=36, labels=['4pDEER'],fig=fig,axs=axs,cmap=[ad.primary_colors[1]]) + ad.plot_optimal_tau(self.current_results['T2_relax'],SNRs,MeasTimes,MaxMeasTime=36, labels=['4pDEER'],fig=fig,axs=axs,cmap=[ad.primary_colors[1]],corr_factor=self.correction_factor) axs.set_title(labels[0]) diff --git a/autodeer/relaxation_autodeer.py b/autodeer/relaxation_autodeer.py index 0418fe4..c071153 100644 --- a/autodeer/relaxation_autodeer.py +++ b/autodeer/relaxation_autodeer.py @@ -225,7 +225,8 @@ def calc_correction_factor(CPanalysis,DEER_fit_result): actual_time = DEER_sequence._estimate_time() *(DEER_fit_result.dataset.nAvgs/DEER_fit_result.dataset.averages) - actual_MNR = DEER_fit_result.MNR + # actual_MNR = DEER_fit_result.MNR + actual_SNR = 1/DEER_fit_result.noiselvl if DEER_sequence.name == '5pDEER': dataset = CPanalysis.dataset @@ -238,7 +239,8 @@ def calc_correction_factor(CPanalysis,DEER_fit_result): est_SNR = V(tau)/(noise*np.sqrt(CP_averages)) est_SNR *= np.sqrt(nPointsInTime(actual_time)/t_axis.shape[0]) - correction_factor = actual_MNR/est_SNR + correction_factor = actual_SNR/est_SNR + elif DEER_sequence.name == '4pDEER': dataset = CPanalysis.dataset CP_averages = dataset.nAvgs * dataset.shots * dataset.nPcyc @@ -250,7 +252,7 @@ def calc_correction_factor(CPanalysis,DEER_fit_result): est_SNR = V(tau)/(noise*np.sqrt(CP_averages)) est_SNR *= np.sqrt(nPointsInTime(actual_time)/t_axis.shape[0]) - correction_factor = actual_MNR/est_SNR + correction_factor = actual_SNR/est_SNR else: correction_factor = 1 From 499f72b4e6d9e4c5ca7b85433618ba3d8bebbee1 Mon Sep 17 00:00:00 2001 From: Hugo Karas Date: Mon, 11 Nov 2024 13:47:04 +0100 Subject: [PATCH 2/2] Updated changelog and dependencies --- docsrc/source/releasenotes.rst | 16 ++++++++++++++++ setup.py | 8 ++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/docsrc/source/releasenotes.rst b/docsrc/source/releasenotes.rst index 5826f74..19527bb 100644 --- a/docsrc/source/releasenotes.rst +++ b/docsrc/source/releasenotes.rst @@ -1,8 +1,24 @@ Release Notes ============= +Version 0.9.0 (2024-11-11): ++++++++++++++++++++++++++++ + +- Faster implmenetation of excite profile +- Implementation of DeerLab based fitting into relaxation traces +- New implementation of correction factor +- Updated MNR and SNR parameters +- Improved versioning (including git branch for dev versions) +- Added a button for keep running (not to automatically stop) +- Implementation of a global waveform precision +- Added autoextending relxation data traces +- New save folder for raw data folder +- Improved calc_DEER_delays function, with new plot + + Version 0.8.0 (TBA): +++++++++++++++++++++++++++ + - Major Support Update for 2D Decoherence - `RefocusedEcho2DSequence` reforumlated to support match normal style - Added 2D Decoherence to the GUI diff --git a/setup.py b/setup.py index 9697138..e8b6070 100644 --- a/setup.py +++ b/setup.py @@ -6,9 +6,9 @@ "Matlab": ["matlabengine"], "Docs": ["sphinx", "furo", "sphinx-gallery", "sphinx-design","myst-parser","sphinx-copybutton","sphinx-toolbox","sphinx-autoapi","sphinxcontrib-bibtex","numpydoc"], "GUI": ["PyQt6","threadpoolctl", "pyinstaller"], - "test": ["pytest", "pytest-cov", "pytest-qt", "pytest-xdist"], + "test": ["pytest", "pytest-cov", "pytest-qt", "pytest-xdist", "GitPython"], } -extras["Dev"] = extras["Docs"] + extras["test"] + ['GitPython'] +extras["Dev"] = extras["Docs"] + extras["test"] setup( name='autoDEER', version=str(__version__), @@ -19,10 +19,10 @@ url = "https://github.com/HKaras/autoDeer", python_requires=">=3.8", install_requires=[ - 'numpy', + 'numpy >= 2.0', 'scipy', 'matplotlib', - 'deerlab >= 1.0', + 'deerlab >= 1.1.4', 'pyyaml', 'reportlab', 'svglib',