From 95957c84d7fb90c8b109ae30b3cce2da0830c90e Mon Sep 17 00:00:00 2001 From: Bruno Manuel Santos Saraiva Date: Mon, 7 Jul 2025 15:02:46 +0100 Subject: [PATCH 1/8] defaulting grad_magnification to 2 --- .../nanopyx.core.transform._le_esrrf.pyx | 12 ++++++------ src/nanopyx/core/transform/_le_esrrf.pyx | 18 +++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/mako_templates/nanopyx.core.transform._le_esrrf.pyx b/src/mako_templates/nanopyx.core.transform._le_esrrf.pyx index ea8afd15..1fc91a8c 100644 --- a/src/mako_templates/nanopyx.core.transform._le_esrrf.pyx +++ b/src/mako_templates/nanopyx.core.transform._le_esrrf.pyx @@ -29,15 +29,15 @@ class eSRRF(LiquidEngine): self._designation = "eSRRF_ST" super().__init__(clear_benchmarks=clear_benchmarks, testing=testing, verbose=verbose) - def run(self, image, magnification: int = 5, grad_magnification: int = 1, radius: float = 1.5, sensitivity: float = 1, doIntensityWeighting: bool = True, run_type=None): + def run(self, image, magnification: int = 5, grad_magnification: int = 2, radius: float = 1.5, sensitivity: float = 1, doIntensityWeighting: bool = True, run_type=None): image = check_image(image) return self._run(image, magnification=magnification, grad_magnification=grad_magnification, radius=radius, sensitivity=sensitivity, doIntensityWeighting=doIntensityWeighting, run_type=run_type) - def benchmark(self, image, magnification: int = 5, grad_magnification: int = 1, radius: float = 1.5, sensitivity: float = 1, doIntensityWeighting: bool = True): + def benchmark(self, image, magnification: int = 5, grad_magnification: int = 2, radius: float = 1.5, sensitivity: float = 1, doIntensityWeighting: bool = True): image = check_image(image) return super().benchmark(image, magnification=magnification, grad_magnification=grad_magnification, radius=radius, sensitivity=sensitivity, doIntensityWeighting=doIntensityWeighting) - def _run_opencl(self, image, magnification=5, grad_magnification=1, radius=1.5, sensitivity=1, doIntensityWeighting=True, device=None, mem_div=1): + def _run_opencl(self, image, magnification=5, grad_magnification=2, radius=1.5, sensitivity=1, doIntensityWeighting=True, device=None, mem_div=1): """ @gpu """ @@ -70,8 +70,8 @@ class eSRRF(LiquidEngine): input_cl = cl.Buffer(cl_ctx, mf.READ_ONLY, self._check_max_buffer_size(image[0:max_slices, :, :].nbytes, dc, max_slices)) output_cl = cl.Buffer(cl_ctx, mf.WRITE_ONLY, self._check_max_buffer_size(np.empty((max_slices, output_shape[1], output_shape[2]), dtype=np.float32).nbytes, dc, max_slices)) magnified_cl = cl.Buffer(cl_ctx, mf.READ_WRITE, self._check_max_buffer_size(np.empty((max_slices, output_shape[1], output_shape[2]), dtype=np.float32).nbytes, dc, max_slices)) - col_kernel_cl = cl.Buffer(cl_ctx, mf.READ_ONLY, self._check_max_buffer_size(np.empty((2,2)).nbytes, dc, max_slices)) - row_kernel_cl = cl.Buffer(cl_ctx, mf.READ_ONLY, self._check_max_buffer_size(np.empty((2,2)).nbytes, dc, max_slices)) + col_kernel_cl = cl.Buffer(cl_ctx, mf.READ_ONLY, self._check_max_buffer_size(np.empty_like(kernely).nbytes, dc, max_slices)) + row_kernel_cl = cl.Buffer(cl_ctx, mf.READ_ONLY, self._check_max_buffer_size(np.empty_like(kernelx).nbytes, dc, max_slices)) cl.enqueue_copy(cl_queue, col_kernel_cl, kernely).wait() cl.enqueue_copy(cl_queue, row_kernel_cl, kernelx).wait() col_gradients_cl = cl.Buffer(cl_ctx, mf.READ_WRITE, self._check_max_buffer_size(np.empty((max_slices, image.shape[1], image.shape[2]), dtype=np.float32).nbytes, dc, max_slices)) @@ -181,7 +181,7 @@ class eSRRF(LiquidEngine): return output_image % for sch in schedulers: - def _run_${sch}(self, image, magnification=5, grad_magnification=1, radius=1.5, sensitivity=1, doIntensityWeighting=True): + def _run_${sch}(self, image, magnification=5, grad_magnification=2, radius=1.5, sensitivity=1, doIntensityWeighting=True): """ @cpu @threaded diff --git a/src/nanopyx/core/transform/_le_esrrf.pyx b/src/nanopyx/core/transform/_le_esrrf.pyx index 20e92b38..ec511196 100644 --- a/src/nanopyx/core/transform/_le_esrrf.pyx +++ b/src/nanopyx/core/transform/_le_esrrf.pyx @@ -27,15 +27,15 @@ class eSRRF(LiquidEngine): self._designation = "eSRRF_ST" super().__init__(clear_benchmarks=clear_benchmarks, testing=testing, verbose=verbose) - def run(self, image, magnification: int = 5, grad_magnification: int = 1, radius: float = 1.5, sensitivity: float = 1, doIntensityWeighting: bool = True, run_type=None): + def run(self, image, magnification: int = 5, grad_magnification: int = 2, radius: float = 1.5, sensitivity: float = 1, doIntensityWeighting: bool = True, run_type=None): image = check_image(image) return self._run(image, magnification=magnification, grad_magnification=grad_magnification, radius=radius, sensitivity=sensitivity, doIntensityWeighting=doIntensityWeighting, run_type=run_type) - def benchmark(self, image, magnification: int = 5, grad_magnification: int = 1, radius: float = 1.5, sensitivity: float = 1, doIntensityWeighting: bool = True): + def benchmark(self, image, magnification: int = 5, grad_magnification: int = 2, radius: float = 1.5, sensitivity: float = 1, doIntensityWeighting: bool = True): image = check_image(image) return super().benchmark(image, magnification=magnification, grad_magnification=grad_magnification, radius=radius, sensitivity=sensitivity, doIntensityWeighting=doIntensityWeighting) - def _run_opencl(self, image, magnification=5, grad_magnification=1, radius=1.5, sensitivity=1, doIntensityWeighting=True, device=None, mem_div=1): + def _run_opencl(self, image, magnification=5, grad_magnification=2, radius=1.5, sensitivity=1, doIntensityWeighting=True, device=None, mem_div=1): """ @gpu """ @@ -68,8 +68,8 @@ class eSRRF(LiquidEngine): input_cl = cl.Buffer(cl_ctx, mf.READ_ONLY, self._check_max_buffer_size(image[0:max_slices, :, :].nbytes, dc, max_slices)) output_cl = cl.Buffer(cl_ctx, mf.WRITE_ONLY, self._check_max_buffer_size(np.empty((max_slices, output_shape[1], output_shape[2]), dtype=np.float32).nbytes, dc, max_slices)) magnified_cl = cl.Buffer(cl_ctx, mf.READ_WRITE, self._check_max_buffer_size(np.empty((max_slices, output_shape[1], output_shape[2]), dtype=np.float32).nbytes, dc, max_slices)) - col_kernel_cl = cl.Buffer(cl_ctx, mf.READ_ONLY, self._check_max_buffer_size(np.empty((2,2)).nbytes, dc, max_slices)) - row_kernel_cl = cl.Buffer(cl_ctx, mf.READ_ONLY, self._check_max_buffer_size(np.empty((2,2)).nbytes, dc, max_slices)) + col_kernel_cl = cl.Buffer(cl_ctx, mf.READ_ONLY, self._check_max_buffer_size(np.empty_like(kernely).nbytes, dc, max_slices)) + row_kernel_cl = cl.Buffer(cl_ctx, mf.READ_ONLY, self._check_max_buffer_size(np.empty_like(kernelx).nbytes, dc, max_slices)) cl.enqueue_copy(cl_queue, col_kernel_cl, kernely).wait() cl.enqueue_copy(cl_queue, row_kernel_cl, kernelx).wait() col_gradients_cl = cl.Buffer(cl_ctx, mf.READ_WRITE, self._check_max_buffer_size(np.empty((max_slices, image.shape[1], image.shape[2]), dtype=np.float32).nbytes, dc, max_slices)) @@ -178,7 +178,7 @@ class eSRRF(LiquidEngine): return output_image - def _run_threaded(self, image, magnification=5, grad_magnification=1, radius=1.5, sensitivity=1, doIntensityWeighting=True): + def _run_threaded(self, image, magnification=5, grad_magnification=2, radius=1.5, sensitivity=1, doIntensityWeighting=True): """ @cpu @threaded @@ -200,7 +200,7 @@ class eSRRF(LiquidEngine): radial_gradients = rgc.run(gradient_col_interp, gradient_row_interp, magnified_image, magnification=magnification, grad_magnification=grad_magnification, radius=radius, sensitivity=sensitivity, doIntensityWeighting=doIntensityWeighting, offset=0, xyoffset=-0.5, angle=np.pi/4, run_type=runtype) return radial_gradients - def _run_threaded_guided(self, image, magnification=5, grad_magnification=1, radius=1.5, sensitivity=1, doIntensityWeighting=True): + def _run_threaded_guided(self, image, magnification=5, grad_magnification=2, radius=1.5, sensitivity=1, doIntensityWeighting=True): """ @cpu @threaded @@ -222,7 +222,7 @@ class eSRRF(LiquidEngine): radial_gradients = rgc.run(gradient_col_interp, gradient_row_interp, magnified_image, magnification=magnification, grad_magnification=grad_magnification, radius=radius, sensitivity=sensitivity, doIntensityWeighting=doIntensityWeighting, offset=0, xyoffset=-0.5, angle=np.pi/4, run_type=runtype) return radial_gradients - def _run_threaded_dynamic(self, image, magnification=5, grad_magnification=1, radius=1.5, sensitivity=1, doIntensityWeighting=True): + def _run_threaded_dynamic(self, image, magnification=5, grad_magnification=2, radius=1.5, sensitivity=1, doIntensityWeighting=True): """ @cpu @threaded @@ -244,7 +244,7 @@ class eSRRF(LiquidEngine): radial_gradients = rgc.run(gradient_col_interp, gradient_row_interp, magnified_image, magnification=magnification, grad_magnification=grad_magnification, radius=radius, sensitivity=sensitivity, doIntensityWeighting=doIntensityWeighting, offset=0, xyoffset=-0.5, angle=np.pi/4, run_type=runtype) return radial_gradients - def _run_threaded_static(self, image, magnification=5, grad_magnification=1, radius=1.5, sensitivity=1, doIntensityWeighting=True): + def _run_threaded_static(self, image, magnification=5, grad_magnification=2, radius=1.5, sensitivity=1, doIntensityWeighting=True): """ @cpu @threaded From 09192327a315830892b3101a1ef6afaeb9bea737 Mon Sep 17 00:00:00 2001 From: Bruno Manuel Santos Saraiva Date: Tue, 8 Jul 2025 10:12:40 +0100 Subject: [PATCH 2/8] added frames_per_timepoint and temporal_correlation params to esrrf workflow --- src/nanopyx/methods/esrrf/eSRRF_workflow.py | 84 ++++++++++++++++----- 1 file changed, 67 insertions(+), 17 deletions(-) diff --git a/src/nanopyx/methods/esrrf/eSRRF_workflow.py b/src/nanopyx/methods/esrrf/eSRRF_workflow.py index 01ae33e8..098369bb 100644 --- a/src/nanopyx/methods/esrrf/eSRRF_workflow.py +++ b/src/nanopyx/methods/esrrf/eSRRF_workflow.py @@ -1,6 +1,9 @@ from ..workflow import Workflow from ...core.transform import eSRRF_ST from ...core.transform.mpcorrector import macro_pixel_corrector +from ...core.transform.sr_temporal_correlations import ( + calculate_eSRRF_temporal_correlations, +) import numpy as np # TODO check correlations and error map @@ -12,6 +15,8 @@ def eSRRF( grad_magnification: int = 1, radius: float = 1.5, sensitivity: float = 1, + frames_per_timepoint: int = 0, + temporal_correlation: str = "AVG", doIntensityWeighting: bool = True, macro_pixel_correction: bool = True, _force_run_type=None, @@ -24,6 +29,8 @@ def eSRRF( magnification (int, optional): Magnification factor (default is 5). radius (float, optional): Radius parameter for eSRRF analysis (default is 1.5). sensitivity (float, optional): Sensitivity parameter for eSRRF analysis (default is 1). + frames_per_timepoint (int, optional): Number of frames per timepoint (default is 0, which means all frames are used). + temporal_correlation (str, optional): Type of temporal correlation to calculate. Options are: AVG, VAR or TAC2 (default is "AVG"). doIntensityWeighting (bool, optional): Enable intensity weighting (default is True). macro_pixel_correction (bool, optional): Enable macro pixel correction (default is True). _force_run_type (str, optional): Force a specific run type for the analysis (default is None). @@ -45,23 +52,66 @@ def eSRRF( - Workflow: The class used to define and run analysis workflows. """ - _eSRRF = Workflow( + if frames_per_timepoint == 0: + frames_per_timepoint = image.shape[0] + elif frames_per_timepoint > image.shape[0]: + frames_per_timepoint = image.shape[0] + + number_of_timepoints = image.shape[0] // frames_per_timepoint + if image.shape[0] % frames_per_timepoint != 0: + number_of_timepoints += 1 + + output_array = np.zeros( ( - eSRRF_ST(verbose=False), - (image,), - { - "magnification": magnification, - "grad_magnification": grad_magnification, - "radius": radius, - "sensitivity": sensitivity, - "doIntensityWeighting": doIntensityWeighting, - }, - ) + number_of_timepoints, + image.shape[1] * magnification, + image.shape[2] * magnification, + ), + dtype=np.float32, ) - if macro_pixel_correction: - return macro_pixel_corrector( - np.asarray(_eSRRF.calculate(_force_run_type=_force_run_type)[0]), - magnification=magnification, + + for i in range(number_of_timepoints): + + _eSRRF = Workflow( + ( + eSRRF_ST(verbose=False), + ( + image[ + frames_per_timepoint + * i : frames_per_timepoint + * (i + 1) + ], + ), + { + "magnification": magnification, + "grad_magnification": grad_magnification, + "radius": radius, + "sensitivity": sensitivity, + "doIntensityWeighting": doIntensityWeighting, + }, + ) ) - else: - return np.asarray(_eSRRF.calculate(_force_run_type=_force_run_type)[0]) + if macro_pixel_correction: + output_array[i] = macro_pixel_corrector( + np.expand_dims( + np.asarray( + calculate_eSRRF_temporal_correlations( + _eSRRF.calculate(_force_run_type=_force_run_type)[ + 0 + ], + temporal_correlation, + ) + ), + axis=0, + ), + magnification=magnification, + ) + else: + output_array[i] = np.asarray( + calculate_eSRRF_temporal_correlations( + _eSRRF.calculate(_force_run_type=_force_run_type)[0], + temporal_correlation, + ) + ) + + return np.squeeze(output_array.astype(np.float32)) From 46adcd244ca980cb2078e9b7cf2cad5cbdddea79 Mon Sep 17 00:00:00 2001 From: Bruno Manuel Santos Saraiva Date: Tue, 8 Jul 2025 10:15:18 +0100 Subject: [PATCH 3/8] updated esrrf ingredient to reflect new changes to esrrf workflow --- src/notebookchef/pantry/methods/esrrf.py | 27 +++++++++--------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/notebookchef/pantry/methods/esrrf.py b/src/notebookchef/pantry/methods/esrrf.py index 76ead076..49bfba82 100644 --- a/src/notebookchef/pantry/methods/esrrf.py +++ b/src/notebookchef/pantry/methods/esrrf.py @@ -30,23 +30,16 @@ def run_esrrf(b): elif frames_per_timepoint > dataset_original.shape[0]: frames_per_timepoint = dataset_original.shape[0] - output = [] - - for i in range(dataset_original.shape[0] // frames_per_timepoint): - block = dataset_original[ - i * frames_per_timepoint : (i + 1) * frames_per_timepoint - ] - result = eSRRF( - block, - magnification=magnification, - radius=ring_radius, - sensitivity=sensitivity, - doIntensityWeighting=True, - macro_pixel_correction=mpcorrection, - ) - output.append( - calculate_eSRRF_temporal_correlations(result, esrrf_order) - ) + output = eSRRF( + dataset_original, + magnification=magnification, + radius=ring_radius, + sensitivity=sensitivity, + doIntensityWeighting=True, + macro_pixel_correction=mpcorrection, + frames_per_timepoint=frames_per_timepoint, + temporal_correlation=esrrf_order, + ) global dataset_esrrf dataset_esrrf = np.array(output) From e24e983d5e5e83a8a0cd63fc437e3dbdda5c415c Mon Sep 17 00:00:00 2001 From: Bruno Manuel Santos Saraiva Date: Tue, 8 Jul 2025 10:15:31 +0100 Subject: [PATCH 4/8] notebooks update --- notebooks/ChannelRegistration.ipynb | 16 +++---- notebooks/DriftCorrection.ipynb | 16 +++---- notebooks/ExampleDataSRRFandQC.ipynb | 40 ++++++++--------- notebooks/NonLocalMeansDenoising.ipynb | 12 ++--- notebooks/ParamSweepandeSRRF.ipynb | 61 ++++++++++++-------------- notebooks/SRMetrics.ipynb | 34 +++++++------- notebooks/SRRFandQC.ipynb | 32 +++++++------- notebooks/eSRRFandQC.ipynb | 59 +++++++++++-------------- 8 files changed, 128 insertions(+), 142 deletions(-) diff --git a/notebooks/ChannelRegistration.ipynb b/notebooks/ChannelRegistration.ipynb index b7794cb2..5667a624 100644 --- a/notebooks/ChannelRegistration.ipynb +++ b/notebooks/ChannelRegistration.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "3a463e61", + "id": "d1bd3a58", "metadata": {}, "source": [ "# NanoPyx \"Codeless\" Jupyter Notebook\n", @@ -22,7 +22,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2c8eefa2", + "id": "0170ae23", "metadata": { "cellView": "form" }, @@ -45,7 +45,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b399241e", + "id": "db56ca9e", "metadata": { "cellView": "form" }, @@ -103,7 +103,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3515d5ba", + "id": "3fd533a0", "metadata": { "cellView": "form" }, @@ -187,7 +187,7 @@ }, { "cell_type": "markdown", - "id": "28fd6b5d", + "id": "131a6cba", "metadata": {}, "source": [ "# Channel Registration Parameters: \n", @@ -205,7 +205,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cc625efd", + "id": "2ebd3b29", "metadata": { "cellView": "form" }, @@ -273,7 +273,7 @@ }, { "cell_type": "markdown", - "id": "0187c8cc", + "id": "9270a8c6", "metadata": {}, "source": [ "## Use the following cell only if you have a previously calculated translation mask\n", @@ -283,7 +283,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b7fa2ef3", + "id": "a5d751db", "metadata": { "cellView": "form" }, diff --git a/notebooks/DriftCorrection.ipynb b/notebooks/DriftCorrection.ipynb index da2cf2f4..3a02d768 100644 --- a/notebooks/DriftCorrection.ipynb +++ b/notebooks/DriftCorrection.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "8000d90a", + "id": "ff4f6f3e", "metadata": {}, "source": [ "# NanoPyx \"Codeless\" Jupyter Notebook\n", @@ -22,7 +22,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8e6267d8", + "id": "78880f77", "metadata": { "cellView": "form" }, @@ -45,7 +45,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8a1ec6e4", + "id": "53da0bb4", "metadata": { "cellView": "form" }, @@ -103,7 +103,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cd931d80", + "id": "81b0b448", "metadata": { "cellView": "form" }, @@ -187,7 +187,7 @@ }, { "cell_type": "markdown", - "id": "c64af72e", + "id": "59ff9893", "metadata": {}, "source": [ "# Drift Correction Parameters: \n", @@ -204,7 +204,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6e00f92e", + "id": "8e137c0e", "metadata": { "cellView": "form" }, @@ -297,7 +297,7 @@ }, { "cell_type": "markdown", - "id": "4dee37ed", + "id": "a41caf63", "metadata": {}, "source": [ "## Use the following cell only if you have a previously calculated drift table\n", @@ -307,7 +307,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e68d4a71", + "id": "55865569", "metadata": { "cellView": "form" }, diff --git a/notebooks/ExampleDataSRRFandQC.ipynb b/notebooks/ExampleDataSRRFandQC.ipynb index e4e7395a..fce437d4 100644 --- a/notebooks/ExampleDataSRRFandQC.ipynb +++ b/notebooks/ExampleDataSRRFandQC.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "0bb114f6", + "id": "23835f54", "metadata": {}, "source": [ "# NanoPyx \"Codeless\" Jupyter Notebook\n", @@ -26,7 +26,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9b1d5a74", + "id": "a0695531", "metadata": { "cellView": "form" }, @@ -49,7 +49,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bf06f12f", + "id": "158220a9", "metadata": { "cellView": "form" }, @@ -106,7 +106,7 @@ }, { "cell_type": "markdown", - "id": "9b40447a", + "id": "d9665298", "metadata": {}, "source": [ "## Next lets create the Data Loader GUI.\n", @@ -117,7 +117,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0facb763", + "id": "54f4792d", "metadata": { "cellView": "form" }, @@ -201,7 +201,7 @@ }, { "cell_type": "markdown", - "id": "9c6e9ba9", + "id": "cfacef8a", "metadata": {}, "source": [ "## Now let's use SRRF to generate a super-resolution image\n", @@ -210,7 +210,7 @@ }, { "cell_type": "markdown", - "id": "5d3afd30", + "id": "dc8e920d", "metadata": {}, "source": [ "# SRRF Parameters:\n", @@ -226,7 +226,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ad5edeff", + "id": "a8247fda", "metadata": { "cellView": "form" }, @@ -334,7 +334,7 @@ }, { "cell_type": "markdown", - "id": "e32a84cf", + "id": "501f0118", "metadata": {}, "source": [ "## Let's use NanoPyx to generate an error map of the SRRF image\n", @@ -344,7 +344,7 @@ { "cell_type": "code", "execution_count": null, - "id": "44184399", + "id": "8680f783", "metadata": { "cellView": "form" }, @@ -499,7 +499,7 @@ }, { "cell_type": "markdown", - "id": "c954bc0c", + "id": "cb382669", "metadata": {}, "source": [ "## Let's compare the resolution of the raw data with the SRRF using FRC and DecorrelationAnalysis. Let's start with calculation the FRC resolution of the raw data (select frame 3 and 11).\n", @@ -508,7 +508,7 @@ }, { "cell_type": "markdown", - "id": "03d6c564", + "id": "3cd252ee", "metadata": {}, "source": [ "# FRC Parameters:\n", @@ -523,7 +523,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3bc9fcaf", + "id": "7c1ebe75", "metadata": { "cellView": "form" }, @@ -583,7 +583,7 @@ }, { "cell_type": "markdown", - "id": "c064f783", + "id": "6a57947c", "metadata": {}, "source": [ "## Now do the same for the SRRF image\n", @@ -593,7 +593,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a15491c4", + "id": "0d07d8d1", "metadata": { "cellView": "form" }, @@ -653,7 +653,7 @@ }, { "cell_type": "markdown", - "id": "b070890b", + "id": "047e84f7", "metadata": {}, "source": [ "## Let's do the same using Decorrelation analysis\n", @@ -662,7 +662,7 @@ }, { "cell_type": "markdown", - "id": "9cf3dcf4", + "id": "c09cabd7", "metadata": {}, "source": [ "# Image Decorrelation Analysis Parameters:\n", @@ -678,7 +678,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bd63a8fe", + "id": "50be195f", "metadata": { "cellView": "form" }, @@ -739,7 +739,7 @@ }, { "cell_type": "markdown", - "id": "adb0d906", + "id": "73a6f4b1", "metadata": {}, "source": [ "## Now let's measure the resolution of the generated SRRF image using Decorrelation analysis\n", @@ -749,7 +749,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c467203c", + "id": "4dff39f1", "metadata": { "cellView": "form" }, diff --git a/notebooks/NonLocalMeansDenoising.ipynb b/notebooks/NonLocalMeansDenoising.ipynb index 784ae4c5..8d583d36 100644 --- a/notebooks/NonLocalMeansDenoising.ipynb +++ b/notebooks/NonLocalMeansDenoising.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "4add2b4d", + "id": "8e774e5d", "metadata": {}, "source": [ "# NanoPyx \"Codeless\" Jupyter Notebook\n", @@ -23,7 +23,7 @@ { "cell_type": "code", "execution_count": null, - "id": "09454d17", + "id": "0587458a", "metadata": { "cellView": "form" }, @@ -46,7 +46,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ffa7c053", + "id": "318d5a6f", "metadata": { "cellView": "form" }, @@ -104,7 +104,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8153398f", + "id": "dd8b1354", "metadata": { "cellView": "form" }, @@ -188,7 +188,7 @@ }, { "cell_type": "markdown", - "id": "1b5bb6d3", + "id": "92e1253a", "metadata": {}, "source": [ "# Use Non-local means denoising on selected data\n", @@ -205,7 +205,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0888b1fe", + "id": "82c366b8", "metadata": { "cellView": "form" }, diff --git a/notebooks/ParamSweepandeSRRF.ipynb b/notebooks/ParamSweepandeSRRF.ipynb index d1ce9e02..c307d069 100644 --- a/notebooks/ParamSweepandeSRRF.ipynb +++ b/notebooks/ParamSweepandeSRRF.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "8047889c", + "id": "a9cf4d35", "metadata": {}, "source": [ "# NanoPyx \"Codeless\" Jupyter Notebook\n", @@ -28,7 +28,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a0d63f0d", + "id": "142e5bba", "metadata": { "cellView": "form" }, @@ -51,7 +51,7 @@ { "cell_type": "code", "execution_count": null, - "id": "43026c0e", + "id": "6a78c39c", "metadata": { "cellView": "form" }, @@ -109,7 +109,7 @@ { "cell_type": "code", "execution_count": null, - "id": "775998a4", + "id": "fb42aa9e", "metadata": { "cellView": "form" }, @@ -193,7 +193,7 @@ }, { "cell_type": "markdown", - "id": "74595e53", + "id": "666d234d", "metadata": {}, "source": [ "# Run a parameter sweep to find the best combination of parameters\n", @@ -210,7 +210,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a5f70766", + "id": "17b4a135", "metadata": { "cellView": "form" }, @@ -275,7 +275,7 @@ { "cell_type": "code", "execution_count": null, - "id": "eb09c35a", + "id": "6ea8aa41", "metadata": { "cellView": "form" }, @@ -313,23 +313,16 @@ " elif frames_per_timepoint > dataset_original.shape[0]:\n", " frames_per_timepoint = dataset_original.shape[0]\n", "\n", - " output = []\n", - "\n", - " for i in range(dataset_original.shape[0] // frames_per_timepoint):\n", - " block = dataset_original[\n", - " i * frames_per_timepoint : (i + 1) * frames_per_timepoint\n", - " ]\n", - " result = eSRRF(\n", - " block,\n", - " magnification=magnification,\n", - " radius=ring_radius,\n", - " sensitivity=sensitivity,\n", - " doIntensityWeighting=True,\n", - " macro_pixel_correction=mpcorrection,\n", - " )\n", - " output.append(\n", - " calculate_eSRRF_temporal_correlations(result, esrrf_order)\n", - " )\n", + " output = eSRRF(\n", + " dataset_original,\n", + " magnification=magnification,\n", + " radius=ring_radius,\n", + " sensitivity=sensitivity,\n", + " doIntensityWeighting=True,\n", + " macro_pixel_correction=mpcorrection,\n", + " frames_per_timepoint=frames_per_timepoint,\n", + " temporal_correlation=esrrf_order,\n", + " )\n", "\n", " global dataset_esrrf\n", " dataset_esrrf = np.array(output)\n", @@ -415,7 +408,7 @@ }, { "cell_type": "markdown", - "id": "54fbdd6a", + "id": "e917335f", "metadata": {}, "source": [ "## Calculate error map for the eSRRF image\n", @@ -425,7 +418,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2fd58492", + "id": "dd0036e1", "metadata": { "cellView": "form" }, @@ -580,7 +573,7 @@ }, { "cell_type": "markdown", - "id": "ee07fd90", + "id": "a99d7294", "metadata": {}, "source": [ "## Calculate FRC resolution of the diffraction limited image\n", @@ -596,7 +589,7 @@ { "cell_type": "code", "execution_count": null, - "id": "674861a8", + "id": "e64aa974", "metadata": { "cellView": "form" }, @@ -656,7 +649,7 @@ }, { "cell_type": "markdown", - "id": "d4b7bb70", + "id": "374e1a1c", "metadata": {}, "source": [ "## Calculate FRC resolution of the SR image\n", @@ -672,7 +665,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9e2c0164", + "id": "910e17cb", "metadata": { "cellView": "form" }, @@ -732,7 +725,7 @@ }, { "cell_type": "markdown", - "id": "765431c5", + "id": "f5318a27", "metadata": {}, "source": [ "## Calculate Decorrelation analysis resolution of the diffraction limited image\n", @@ -749,7 +742,7 @@ { "cell_type": "code", "execution_count": null, - "id": "abc6f7eb", + "id": "0621709f", "metadata": { "cellView": "form" }, @@ -810,7 +803,7 @@ }, { "cell_type": "markdown", - "id": "4fccd529", + "id": "ade51d5f", "metadata": {}, "source": [ "## Calculate Decorrelation analysis resolution of the SR image\n", @@ -827,7 +820,7 @@ { "cell_type": "code", "execution_count": null, - "id": "02da8d00", + "id": "af76a08f", "metadata": { "cellView": "form" }, diff --git a/notebooks/SRMetrics.ipynb b/notebooks/SRMetrics.ipynb index 3736e701..3af55f93 100644 --- a/notebooks/SRMetrics.ipynb +++ b/notebooks/SRMetrics.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "97e5fd86", + "id": "cde8ab1d", "metadata": {}, "source": [ "# NanoPyx \"Codeless\" Jupyter Notebook\n", @@ -26,7 +26,7 @@ { "cell_type": "code", "execution_count": null, - "id": "951d88a7", + "id": "4d5bb7f6", "metadata": { "cellView": "form" }, @@ -49,7 +49,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f45244bb", + "id": "f9274f43", "metadata": { "cellView": "form" }, @@ -106,7 +106,7 @@ }, { "cell_type": "markdown", - "id": "3fdade62", + "id": "89af747f", "metadata": {}, "source": [ "## Load difraction limited image (only needed if you want to use the FRC and Decorrelation analysis on this image or if you want to perform the Error Map analysis)\n", @@ -116,7 +116,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ca1e5bec", + "id": "b568ad83", "metadata": { "cellView": "form" }, @@ -200,7 +200,7 @@ }, { "cell_type": "markdown", - "id": "664ed11e", + "id": "fdfb6e02", "metadata": {}, "source": [ "## Load super-resolved image\n", @@ -210,7 +210,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8e442e2e", + "id": "acb3db53", "metadata": { "cellView": "form" }, @@ -294,7 +294,7 @@ }, { "cell_type": "markdown", - "id": "67256b12", + "id": "cb7526e8", "metadata": {}, "source": [ "## Calculate Error Map\n", @@ -304,7 +304,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9459ed67", + "id": "4c538f84", "metadata": { "cellView": "form" }, @@ -459,7 +459,7 @@ }, { "cell_type": "markdown", - "id": "43e793e6", + "id": "8e9bad06", "metadata": {}, "source": [ "# Calculate FRC of the diffraction limited image\n", @@ -475,7 +475,7 @@ { "cell_type": "code", "execution_count": null, - "id": "64b5bca2", + "id": "32552f3c", "metadata": { "cellView": "form" }, @@ -535,7 +535,7 @@ }, { "cell_type": "markdown", - "id": "74a8584c", + "id": "ba854f28", "metadata": {}, "source": [ "# Calculate FRC of the SR image\n", @@ -551,7 +551,7 @@ { "cell_type": "code", "execution_count": null, - "id": "975eed33", + "id": "a20baec2", "metadata": { "cellView": "form" }, @@ -611,7 +611,7 @@ }, { "cell_type": "markdown", - "id": "e4344b4a", + "id": "88c19692", "metadata": {}, "source": [ "# Calculate Decorrelation analysis of diffraction limited image\n", @@ -628,7 +628,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5924d95f", + "id": "47adeabf", "metadata": { "cellView": "form" }, @@ -689,7 +689,7 @@ }, { "cell_type": "markdown", - "id": "a9ff5221", + "id": "c1803999", "metadata": {}, "source": [ "# Calculate Decorrelation analysis of SR image\n", @@ -706,7 +706,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fed6f580", + "id": "6f061a54", "metadata": { "cellView": "form" }, diff --git a/notebooks/SRRFandQC.ipynb b/notebooks/SRRFandQC.ipynb index e6545c90..7c178795 100644 --- a/notebooks/SRRFandQC.ipynb +++ b/notebooks/SRRFandQC.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "a0c4a106", + "id": "073d449e", "metadata": {}, "source": [ "# NanoPyx \"Codeless\" Jupyter Notebook\n", @@ -28,7 +28,7 @@ { "cell_type": "code", "execution_count": null, - "id": "378e76be", + "id": "6ecd4688", "metadata": { "cellView": "form" }, @@ -51,7 +51,7 @@ { "cell_type": "code", "execution_count": null, - "id": "093cec67", + "id": "31752f76", "metadata": { "cellView": "form" }, @@ -109,7 +109,7 @@ { "cell_type": "code", "execution_count": null, - "id": "303b232b", + "id": "0b31426c", "metadata": { "cellView": "form" }, @@ -193,7 +193,7 @@ }, { "cell_type": "markdown", - "id": "f1ad7f42", + "id": "0416a850", "metadata": {}, "source": [ "# Use SRRF to generate a super-resolved image\n", @@ -210,7 +210,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3c82b75d", + "id": "3e15e452", "metadata": { "cellView": "form" }, @@ -318,7 +318,7 @@ }, { "cell_type": "markdown", - "id": "08a8cd23", + "id": "672008de", "metadata": {}, "source": [ "## Calculate error map for the SRRF image\n", @@ -328,7 +328,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ee868b6a", + "id": "9856368b", "metadata": { "cellView": "form" }, @@ -483,7 +483,7 @@ }, { "cell_type": "markdown", - "id": "b83edb6a", + "id": "d9a9a239", "metadata": {}, "source": [ "## Calculate FRC resolution of the diffraction limited image\n", @@ -499,7 +499,7 @@ { "cell_type": "code", "execution_count": null, - "id": "267e9345", + "id": "c5d6fb55", "metadata": { "cellView": "form" }, @@ -559,7 +559,7 @@ }, { "cell_type": "markdown", - "id": "d9c9df13", + "id": "63214092", "metadata": {}, "source": [ "## Calculate FRC resolution of the SR image\n", @@ -575,7 +575,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f4b3a01b", + "id": "f71a1440", "metadata": { "cellView": "form" }, @@ -635,7 +635,7 @@ }, { "cell_type": "markdown", - "id": "d3de6597", + "id": "9665df43", "metadata": {}, "source": [ "## Calculate Decorrelation analysis resolution of the diffraction limited image\n", @@ -652,7 +652,7 @@ { "cell_type": "code", "execution_count": null, - "id": "298b3cea", + "id": "e4b9ffc4", "metadata": { "cellView": "form" }, @@ -713,7 +713,7 @@ }, { "cell_type": "markdown", - "id": "aba479b1", + "id": "1848c48b", "metadata": {}, "source": [ "## Calculate Decorrelation analysis resolution of the SR image\n", @@ -730,7 +730,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c050dbdd", + "id": "9b5b4d73", "metadata": { "cellView": "form" }, diff --git a/notebooks/eSRRFandQC.ipynb b/notebooks/eSRRFandQC.ipynb index 7be611a1..04e72d0f 100644 --- a/notebooks/eSRRFandQC.ipynb +++ b/notebooks/eSRRFandQC.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "8416580c", + "id": "d2590382", "metadata": {}, "source": [ "# NanoPyx \"Codeless\" Jupyter Notebook\n", @@ -28,7 +28,7 @@ { "cell_type": "code", "execution_count": null, - "id": "117138df", + "id": "b5dfc7ec", "metadata": { "cellView": "form" }, @@ -51,7 +51,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f8d47fc3", + "id": "cd5b6e41", "metadata": { "cellView": "form" }, @@ -109,7 +109,7 @@ { "cell_type": "code", "execution_count": null, - "id": "16c0ffe7", + "id": "af76cd71", "metadata": { "cellView": "form" }, @@ -193,7 +193,7 @@ }, { "cell_type": "markdown", - "id": "ac124508", + "id": "290f532b", "metadata": {}, "source": [ "# Use eSRRF to generate a super-resolved image\n", @@ -210,7 +210,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d31adb14", + "id": "49e535c2", "metadata": { "cellView": "form" }, @@ -248,23 +248,16 @@ " elif frames_per_timepoint > dataset_original.shape[0]:\n", " frames_per_timepoint = dataset_original.shape[0]\n", "\n", - " output = []\n", - "\n", - " for i in range(dataset_original.shape[0] // frames_per_timepoint):\n", - " block = dataset_original[\n", - " i * frames_per_timepoint : (i + 1) * frames_per_timepoint\n", - " ]\n", - " result = eSRRF(\n", - " block,\n", - " magnification=magnification,\n", - " radius=ring_radius,\n", - " sensitivity=sensitivity,\n", - " doIntensityWeighting=True,\n", - " macro_pixel_correction=mpcorrection,\n", - " )\n", - " output.append(\n", - " calculate_eSRRF_temporal_correlations(result, esrrf_order)\n", - " )\n", + " output = eSRRF(\n", + " dataset_original,\n", + " magnification=magnification,\n", + " radius=ring_radius,\n", + " sensitivity=sensitivity,\n", + " doIntensityWeighting=True,\n", + " macro_pixel_correction=mpcorrection,\n", + " frames_per_timepoint=frames_per_timepoint,\n", + " temporal_correlation=esrrf_order,\n", + " )\n", "\n", " global dataset_esrrf\n", " dataset_esrrf = np.array(output)\n", @@ -350,7 +343,7 @@ }, { "cell_type": "markdown", - "id": "6688cee1", + "id": "8c4e1369", "metadata": {}, "source": [ "## Calculate error map for the eSRRF image\n", @@ -360,7 +353,7 @@ { "cell_type": "code", "execution_count": null, - "id": "654a97c7", + "id": "39242a02", "metadata": { "cellView": "form" }, @@ -515,7 +508,7 @@ }, { "cell_type": "markdown", - "id": "cae6921f", + "id": "8e4d1360", "metadata": {}, "source": [ "## Calculate FRC resolution of the diffraction limited image\n", @@ -531,7 +524,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f767f72e", + "id": "147d3c09", "metadata": { "cellView": "form" }, @@ -591,7 +584,7 @@ }, { "cell_type": "markdown", - "id": "b277a488", + "id": "880b1af8", "metadata": {}, "source": [ "## Calculate FRC resolution of the SR image\n", @@ -607,7 +600,7 @@ { "cell_type": "code", "execution_count": null, - "id": "60ed9d03", + "id": "1d65f715", "metadata": { "cellView": "form" }, @@ -667,7 +660,7 @@ }, { "cell_type": "markdown", - "id": "e69fce14", + "id": "e77143ff", "metadata": {}, "source": [ "## Calculate Decorrelation analysis resolution of the diffraction limited image\n", @@ -684,7 +677,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5a627d33", + "id": "d3eb065e", "metadata": { "cellView": "form" }, @@ -745,7 +738,7 @@ }, { "cell_type": "markdown", - "id": "b63fc518", + "id": "ee1b5429", "metadata": {}, "source": [ "## Calculate Decorrelation analysis resolution of the SR image\n", @@ -762,7 +755,7 @@ { "cell_type": "code", "execution_count": null, - "id": "adfb20e3", + "id": "635185aa", "metadata": { "cellView": "form" }, From 6b70f081aae3c6c4816378cfda36c707fd1eb787 Mon Sep 17 00:00:00 2001 From: Bruno Manuel Santos Saraiva Date: Tue, 8 Jul 2025 10:16:08 +0100 Subject: [PATCH 5/8] removed leftover variables --- src/notebookchef/pantry/methods/esrrf.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/notebookchef/pantry/methods/esrrf.py b/src/notebookchef/pantry/methods/esrrf.py index 49bfba82..8f3cceba 100644 --- a/src/notebookchef/pantry/methods/esrrf.py +++ b/src/notebookchef/pantry/methods/esrrf.py @@ -25,10 +25,6 @@ def run_esrrf(b): # disable button while running gui_esrrf["run"].disabled = True gui_esrrf["run"].description = "Running..." - if frames_per_timepoint == 0: - frames_per_timepoint = dataset_original.shape[0] - elif frames_per_timepoint > dataset_original.shape[0]: - frames_per_timepoint = dataset_original.shape[0] output = eSRRF( dataset_original, From 28fd66c39fc64eb7eb3e0dfd061fcd70740958a1 Mon Sep 17 00:00:00 2001 From: Bruno Manuel Santos Saraiva Date: Tue, 8 Jul 2025 10:16:20 +0100 Subject: [PATCH 6/8] notebooks update --- notebooks/ChannelRegistration.ipynb | 16 +++++------ notebooks/DriftCorrection.ipynb | 16 +++++------ notebooks/ExampleDataSRRFandQC.ipynb | 40 +++++++++++++------------- notebooks/NonLocalMeansDenoising.ipynb | 12 ++++---- notebooks/ParamSweepandeSRRF.ipynb | 38 +++++++++++------------- notebooks/SRMetrics.ipynb | 34 +++++++++++----------- notebooks/SRRFandQC.ipynb | 32 ++++++++++----------- notebooks/eSRRFandQC.ipynb | 36 +++++++++++------------ 8 files changed, 108 insertions(+), 116 deletions(-) diff --git a/notebooks/ChannelRegistration.ipynb b/notebooks/ChannelRegistration.ipynb index 5667a624..3479fd7a 100644 --- a/notebooks/ChannelRegistration.ipynb +++ b/notebooks/ChannelRegistration.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "d1bd3a58", + "id": "adc06056", "metadata": {}, "source": [ "# NanoPyx \"Codeless\" Jupyter Notebook\n", @@ -22,7 +22,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0170ae23", + "id": "5849fa88", "metadata": { "cellView": "form" }, @@ -45,7 +45,7 @@ { "cell_type": "code", "execution_count": null, - "id": "db56ca9e", + "id": "9f1e02c2", "metadata": { "cellView": "form" }, @@ -103,7 +103,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3fd533a0", + "id": "1ecca89e", "metadata": { "cellView": "form" }, @@ -187,7 +187,7 @@ }, { "cell_type": "markdown", - "id": "131a6cba", + "id": "ec09efb1", "metadata": {}, "source": [ "# Channel Registration Parameters: \n", @@ -205,7 +205,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2ebd3b29", + "id": "b06dfc66", "metadata": { "cellView": "form" }, @@ -273,7 +273,7 @@ }, { "cell_type": "markdown", - "id": "9270a8c6", + "id": "7224e975", "metadata": {}, "source": [ "## Use the following cell only if you have a previously calculated translation mask\n", @@ -283,7 +283,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a5d751db", + "id": "edb303a6", "metadata": { "cellView": "form" }, diff --git a/notebooks/DriftCorrection.ipynb b/notebooks/DriftCorrection.ipynb index 3a02d768..4af79977 100644 --- a/notebooks/DriftCorrection.ipynb +++ b/notebooks/DriftCorrection.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "ff4f6f3e", + "id": "e7c865cd", "metadata": {}, "source": [ "# NanoPyx \"Codeless\" Jupyter Notebook\n", @@ -22,7 +22,7 @@ { "cell_type": "code", "execution_count": null, - "id": "78880f77", + "id": "e2314904", "metadata": { "cellView": "form" }, @@ -45,7 +45,7 @@ { "cell_type": "code", "execution_count": null, - "id": "53da0bb4", + "id": "96f0af5a", "metadata": { "cellView": "form" }, @@ -103,7 +103,7 @@ { "cell_type": "code", "execution_count": null, - "id": "81b0b448", + "id": "1541817a", "metadata": { "cellView": "form" }, @@ -187,7 +187,7 @@ }, { "cell_type": "markdown", - "id": "59ff9893", + "id": "a6f608a3", "metadata": {}, "source": [ "# Drift Correction Parameters: \n", @@ -204,7 +204,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8e137c0e", + "id": "47c6e626", "metadata": { "cellView": "form" }, @@ -297,7 +297,7 @@ }, { "cell_type": "markdown", - "id": "a41caf63", + "id": "f082a781", "metadata": {}, "source": [ "## Use the following cell only if you have a previously calculated drift table\n", @@ -307,7 +307,7 @@ { "cell_type": "code", "execution_count": null, - "id": "55865569", + "id": "139cbeb0", "metadata": { "cellView": "form" }, diff --git a/notebooks/ExampleDataSRRFandQC.ipynb b/notebooks/ExampleDataSRRFandQC.ipynb index fce437d4..3e61b482 100644 --- a/notebooks/ExampleDataSRRFandQC.ipynb +++ b/notebooks/ExampleDataSRRFandQC.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "23835f54", + "id": "d8d514e3", "metadata": {}, "source": [ "# NanoPyx \"Codeless\" Jupyter Notebook\n", @@ -26,7 +26,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a0695531", + "id": "b7db11f3", "metadata": { "cellView": "form" }, @@ -49,7 +49,7 @@ { "cell_type": "code", "execution_count": null, - "id": "158220a9", + "id": "26dea83e", "metadata": { "cellView": "form" }, @@ -106,7 +106,7 @@ }, { "cell_type": "markdown", - "id": "d9665298", + "id": "f374a5ac", "metadata": {}, "source": [ "## Next lets create the Data Loader GUI.\n", @@ -117,7 +117,7 @@ { "cell_type": "code", "execution_count": null, - "id": "54f4792d", + "id": "49736d21", "metadata": { "cellView": "form" }, @@ -201,7 +201,7 @@ }, { "cell_type": "markdown", - "id": "cfacef8a", + "id": "1a631b2f", "metadata": {}, "source": [ "## Now let's use SRRF to generate a super-resolution image\n", @@ -210,7 +210,7 @@ }, { "cell_type": "markdown", - "id": "dc8e920d", + "id": "45d0fda3", "metadata": {}, "source": [ "# SRRF Parameters:\n", @@ -226,7 +226,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a8247fda", + "id": "2981320f", "metadata": { "cellView": "form" }, @@ -334,7 +334,7 @@ }, { "cell_type": "markdown", - "id": "501f0118", + "id": "0232bb0b", "metadata": {}, "source": [ "## Let's use NanoPyx to generate an error map of the SRRF image\n", @@ -344,7 +344,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8680f783", + "id": "186ff2ea", "metadata": { "cellView": "form" }, @@ -499,7 +499,7 @@ }, { "cell_type": "markdown", - "id": "cb382669", + "id": "162dc7db", "metadata": {}, "source": [ "## Let's compare the resolution of the raw data with the SRRF using FRC and DecorrelationAnalysis. Let's start with calculation the FRC resolution of the raw data (select frame 3 and 11).\n", @@ -508,7 +508,7 @@ }, { "cell_type": "markdown", - "id": "3cd252ee", + "id": "0a8f2ad1", "metadata": {}, "source": [ "# FRC Parameters:\n", @@ -523,7 +523,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7c1ebe75", + "id": "0104860b", "metadata": { "cellView": "form" }, @@ -583,7 +583,7 @@ }, { "cell_type": "markdown", - "id": "6a57947c", + "id": "3b1cc7dd", "metadata": {}, "source": [ "## Now do the same for the SRRF image\n", @@ -593,7 +593,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0d07d8d1", + "id": "305ce249", "metadata": { "cellView": "form" }, @@ -653,7 +653,7 @@ }, { "cell_type": "markdown", - "id": "047e84f7", + "id": "7626a919", "metadata": {}, "source": [ "## Let's do the same using Decorrelation analysis\n", @@ -662,7 +662,7 @@ }, { "cell_type": "markdown", - "id": "c09cabd7", + "id": "c32ac330", "metadata": {}, "source": [ "# Image Decorrelation Analysis Parameters:\n", @@ -678,7 +678,7 @@ { "cell_type": "code", "execution_count": null, - "id": "50be195f", + "id": "6efd1941", "metadata": { "cellView": "form" }, @@ -739,7 +739,7 @@ }, { "cell_type": "markdown", - "id": "73a6f4b1", + "id": "99af2031", "metadata": {}, "source": [ "## Now let's measure the resolution of the generated SRRF image using Decorrelation analysis\n", @@ -749,7 +749,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4dff39f1", + "id": "e966123f", "metadata": { "cellView": "form" }, diff --git a/notebooks/NonLocalMeansDenoising.ipynb b/notebooks/NonLocalMeansDenoising.ipynb index 8d583d36..6de29736 100644 --- a/notebooks/NonLocalMeansDenoising.ipynb +++ b/notebooks/NonLocalMeansDenoising.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "8e774e5d", + "id": "8dc1ae65", "metadata": {}, "source": [ "# NanoPyx \"Codeless\" Jupyter Notebook\n", @@ -23,7 +23,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0587458a", + "id": "3d6a85bd", "metadata": { "cellView": "form" }, @@ -46,7 +46,7 @@ { "cell_type": "code", "execution_count": null, - "id": "318d5a6f", + "id": "4f9ba1b8", "metadata": { "cellView": "form" }, @@ -104,7 +104,7 @@ { "cell_type": "code", "execution_count": null, - "id": "dd8b1354", + "id": "759776aa", "metadata": { "cellView": "form" }, @@ -188,7 +188,7 @@ }, { "cell_type": "markdown", - "id": "92e1253a", + "id": "39ad63d4", "metadata": {}, "source": [ "# Use Non-local means denoising on selected data\n", @@ -205,7 +205,7 @@ { "cell_type": "code", "execution_count": null, - "id": "82c366b8", + "id": "b02ad033", "metadata": { "cellView": "form" }, diff --git a/notebooks/ParamSweepandeSRRF.ipynb b/notebooks/ParamSweepandeSRRF.ipynb index c307d069..8df4af77 100644 --- a/notebooks/ParamSweepandeSRRF.ipynb +++ b/notebooks/ParamSweepandeSRRF.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "a9cf4d35", + "id": "1e895ab9", "metadata": {}, "source": [ "# NanoPyx \"Codeless\" Jupyter Notebook\n", @@ -28,7 +28,7 @@ { "cell_type": "code", "execution_count": null, - "id": "142e5bba", + "id": "6ef0870e", "metadata": { "cellView": "form" }, @@ -51,7 +51,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6a78c39c", + "id": "1265318e", "metadata": { "cellView": "form" }, @@ -109,7 +109,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fb42aa9e", + "id": "976710b8", "metadata": { "cellView": "form" }, @@ -193,7 +193,7 @@ }, { "cell_type": "markdown", - "id": "666d234d", + "id": "3f123bb1", "metadata": {}, "source": [ "# Run a parameter sweep to find the best combination of parameters\n", @@ -210,7 +210,7 @@ { "cell_type": "code", "execution_count": null, - "id": "17b4a135", + "id": "c90098f8", "metadata": { "cellView": "form" }, @@ -275,7 +275,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6ea8aa41", + "id": "2525bedc", "metadata": { "cellView": "form" }, @@ -308,10 +308,6 @@ " # disable button while running\n", " gui_esrrf[\"run\"].disabled = True\n", " gui_esrrf[\"run\"].description = \"Running...\"\n", - " if frames_per_timepoint == 0:\n", - " frames_per_timepoint = dataset_original.shape[0]\n", - " elif frames_per_timepoint > dataset_original.shape[0]:\n", - " frames_per_timepoint = dataset_original.shape[0]\n", "\n", " output = eSRRF(\n", " dataset_original,\n", @@ -408,7 +404,7 @@ }, { "cell_type": "markdown", - "id": "e917335f", + "id": "f1ab5a3b", "metadata": {}, "source": [ "## Calculate error map for the eSRRF image\n", @@ -418,7 +414,7 @@ { "cell_type": "code", "execution_count": null, - "id": "dd0036e1", + "id": "0206ceef", "metadata": { "cellView": "form" }, @@ -573,7 +569,7 @@ }, { "cell_type": "markdown", - "id": "a99d7294", + "id": "1a1ddddb", "metadata": {}, "source": [ "## Calculate FRC resolution of the diffraction limited image\n", @@ -589,7 +585,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e64aa974", + "id": "63e3ab75", "metadata": { "cellView": "form" }, @@ -649,7 +645,7 @@ }, { "cell_type": "markdown", - "id": "374e1a1c", + "id": "a7f31be2", "metadata": {}, "source": [ "## Calculate FRC resolution of the SR image\n", @@ -665,7 +661,7 @@ { "cell_type": "code", "execution_count": null, - "id": "910e17cb", + "id": "d55748a5", "metadata": { "cellView": "form" }, @@ -725,7 +721,7 @@ }, { "cell_type": "markdown", - "id": "f5318a27", + "id": "504ba5c7", "metadata": {}, "source": [ "## Calculate Decorrelation analysis resolution of the diffraction limited image\n", @@ -742,7 +738,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0621709f", + "id": "533983ae", "metadata": { "cellView": "form" }, @@ -803,7 +799,7 @@ }, { "cell_type": "markdown", - "id": "ade51d5f", + "id": "e562a43d", "metadata": {}, "source": [ "## Calculate Decorrelation analysis resolution of the SR image\n", @@ -820,7 +816,7 @@ { "cell_type": "code", "execution_count": null, - "id": "af76a08f", + "id": "7ff3f203", "metadata": { "cellView": "form" }, diff --git a/notebooks/SRMetrics.ipynb b/notebooks/SRMetrics.ipynb index 3af55f93..e16592a3 100644 --- a/notebooks/SRMetrics.ipynb +++ b/notebooks/SRMetrics.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "cde8ab1d", + "id": "2ceb6385", "metadata": {}, "source": [ "# NanoPyx \"Codeless\" Jupyter Notebook\n", @@ -26,7 +26,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4d5bb7f6", + "id": "d91c4601", "metadata": { "cellView": "form" }, @@ -49,7 +49,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f9274f43", + "id": "d304611a", "metadata": { "cellView": "form" }, @@ -106,7 +106,7 @@ }, { "cell_type": "markdown", - "id": "89af747f", + "id": "1929eaaa", "metadata": {}, "source": [ "## Load difraction limited image (only needed if you want to use the FRC and Decorrelation analysis on this image or if you want to perform the Error Map analysis)\n", @@ -116,7 +116,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b568ad83", + "id": "7d643d89", "metadata": { "cellView": "form" }, @@ -200,7 +200,7 @@ }, { "cell_type": "markdown", - "id": "fdfb6e02", + "id": "77554c08", "metadata": {}, "source": [ "## Load super-resolved image\n", @@ -210,7 +210,7 @@ { "cell_type": "code", "execution_count": null, - "id": "acb3db53", + "id": "17ff8563", "metadata": { "cellView": "form" }, @@ -294,7 +294,7 @@ }, { "cell_type": "markdown", - "id": "cb7526e8", + "id": "e6d69951", "metadata": {}, "source": [ "## Calculate Error Map\n", @@ -304,7 +304,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4c538f84", + "id": "a3dae658", "metadata": { "cellView": "form" }, @@ -459,7 +459,7 @@ }, { "cell_type": "markdown", - "id": "8e9bad06", + "id": "352c361f", "metadata": {}, "source": [ "# Calculate FRC of the diffraction limited image\n", @@ -475,7 +475,7 @@ { "cell_type": "code", "execution_count": null, - "id": "32552f3c", + "id": "f0ce8ec6", "metadata": { "cellView": "form" }, @@ -535,7 +535,7 @@ }, { "cell_type": "markdown", - "id": "ba854f28", + "id": "541354b7", "metadata": {}, "source": [ "# Calculate FRC of the SR image\n", @@ -551,7 +551,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a20baec2", + "id": "b652c0ae", "metadata": { "cellView": "form" }, @@ -611,7 +611,7 @@ }, { "cell_type": "markdown", - "id": "88c19692", + "id": "9683af87", "metadata": {}, "source": [ "# Calculate Decorrelation analysis of diffraction limited image\n", @@ -628,7 +628,7 @@ { "cell_type": "code", "execution_count": null, - "id": "47adeabf", + "id": "7c187366", "metadata": { "cellView": "form" }, @@ -689,7 +689,7 @@ }, { "cell_type": "markdown", - "id": "c1803999", + "id": "141500cc", "metadata": {}, "source": [ "# Calculate Decorrelation analysis of SR image\n", @@ -706,7 +706,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6f061a54", + "id": "e2449b79", "metadata": { "cellView": "form" }, diff --git a/notebooks/SRRFandQC.ipynb b/notebooks/SRRFandQC.ipynb index 7c178795..cf3d8026 100644 --- a/notebooks/SRRFandQC.ipynb +++ b/notebooks/SRRFandQC.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "073d449e", + "id": "b5b962fb", "metadata": {}, "source": [ "# NanoPyx \"Codeless\" Jupyter Notebook\n", @@ -28,7 +28,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6ecd4688", + "id": "e60b32e5", "metadata": { "cellView": "form" }, @@ -51,7 +51,7 @@ { "cell_type": "code", "execution_count": null, - "id": "31752f76", + "id": "34acafeb", "metadata": { "cellView": "form" }, @@ -109,7 +109,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0b31426c", + "id": "e750a416", "metadata": { "cellView": "form" }, @@ -193,7 +193,7 @@ }, { "cell_type": "markdown", - "id": "0416a850", + "id": "46429ac7", "metadata": {}, "source": [ "# Use SRRF to generate a super-resolved image\n", @@ -210,7 +210,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3e15e452", + "id": "1c8153bf", "metadata": { "cellView": "form" }, @@ -318,7 +318,7 @@ }, { "cell_type": "markdown", - "id": "672008de", + "id": "1930fceb", "metadata": {}, "source": [ "## Calculate error map for the SRRF image\n", @@ -328,7 +328,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9856368b", + "id": "a030e7ca", "metadata": { "cellView": "form" }, @@ -483,7 +483,7 @@ }, { "cell_type": "markdown", - "id": "d9a9a239", + "id": "625616d5", "metadata": {}, "source": [ "## Calculate FRC resolution of the diffraction limited image\n", @@ -499,7 +499,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c5d6fb55", + "id": "86e99e2d", "metadata": { "cellView": "form" }, @@ -559,7 +559,7 @@ }, { "cell_type": "markdown", - "id": "63214092", + "id": "53aeaae6", "metadata": {}, "source": [ "## Calculate FRC resolution of the SR image\n", @@ -575,7 +575,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f71a1440", + "id": "83695311", "metadata": { "cellView": "form" }, @@ -635,7 +635,7 @@ }, { "cell_type": "markdown", - "id": "9665df43", + "id": "848ec406", "metadata": {}, "source": [ "## Calculate Decorrelation analysis resolution of the diffraction limited image\n", @@ -652,7 +652,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e4b9ffc4", + "id": "4437b7b2", "metadata": { "cellView": "form" }, @@ -713,7 +713,7 @@ }, { "cell_type": "markdown", - "id": "1848c48b", + "id": "c4b4cd75", "metadata": {}, "source": [ "## Calculate Decorrelation analysis resolution of the SR image\n", @@ -730,7 +730,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9b5b4d73", + "id": "7c1af074", "metadata": { "cellView": "form" }, diff --git a/notebooks/eSRRFandQC.ipynb b/notebooks/eSRRFandQC.ipynb index 04e72d0f..3f00df8e 100644 --- a/notebooks/eSRRFandQC.ipynb +++ b/notebooks/eSRRFandQC.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "d2590382", + "id": "5f1d843d", "metadata": {}, "source": [ "# NanoPyx \"Codeless\" Jupyter Notebook\n", @@ -28,7 +28,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b5dfc7ec", + "id": "18d54342", "metadata": { "cellView": "form" }, @@ -51,7 +51,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cd5b6e41", + "id": "cdd9b61d", "metadata": { "cellView": "form" }, @@ -109,7 +109,7 @@ { "cell_type": "code", "execution_count": null, - "id": "af76cd71", + "id": "89c05f1b", "metadata": { "cellView": "form" }, @@ -193,7 +193,7 @@ }, { "cell_type": "markdown", - "id": "290f532b", + "id": "18a94a49", "metadata": {}, "source": [ "# Use eSRRF to generate a super-resolved image\n", @@ -210,7 +210,7 @@ { "cell_type": "code", "execution_count": null, - "id": "49e535c2", + "id": "322720a0", "metadata": { "cellView": "form" }, @@ -243,10 +243,6 @@ " # disable button while running\n", " gui_esrrf[\"run\"].disabled = True\n", " gui_esrrf[\"run\"].description = \"Running...\"\n", - " if frames_per_timepoint == 0:\n", - " frames_per_timepoint = dataset_original.shape[0]\n", - " elif frames_per_timepoint > dataset_original.shape[0]:\n", - " frames_per_timepoint = dataset_original.shape[0]\n", "\n", " output = eSRRF(\n", " dataset_original,\n", @@ -343,7 +339,7 @@ }, { "cell_type": "markdown", - "id": "8c4e1369", + "id": "b6226154", "metadata": {}, "source": [ "## Calculate error map for the eSRRF image\n", @@ -353,7 +349,7 @@ { "cell_type": "code", "execution_count": null, - "id": "39242a02", + "id": "a93a23e6", "metadata": { "cellView": "form" }, @@ -508,7 +504,7 @@ }, { "cell_type": "markdown", - "id": "8e4d1360", + "id": "bc2d28e6", "metadata": {}, "source": [ "## Calculate FRC resolution of the diffraction limited image\n", @@ -524,7 +520,7 @@ { "cell_type": "code", "execution_count": null, - "id": "147d3c09", + "id": "7b737a13", "metadata": { "cellView": "form" }, @@ -584,7 +580,7 @@ }, { "cell_type": "markdown", - "id": "880b1af8", + "id": "e97787d3", "metadata": {}, "source": [ "## Calculate FRC resolution of the SR image\n", @@ -600,7 +596,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1d65f715", + "id": "ad9d9488", "metadata": { "cellView": "form" }, @@ -660,7 +656,7 @@ }, { "cell_type": "markdown", - "id": "e77143ff", + "id": "b30ffccc", "metadata": {}, "source": [ "## Calculate Decorrelation analysis resolution of the diffraction limited image\n", @@ -677,7 +673,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d3eb065e", + "id": "ef3bf607", "metadata": { "cellView": "form" }, @@ -738,7 +734,7 @@ }, { "cell_type": "markdown", - "id": "ee1b5429", + "id": "629b67d0", "metadata": {}, "source": [ "## Calculate Decorrelation analysis resolution of the SR image\n", @@ -755,7 +751,7 @@ { "cell_type": "code", "execution_count": null, - "id": "635185aa", + "id": "d667d440", "metadata": { "cellView": "form" }, From 65c44aca81d9a7d15d881802aa25ab97065f7266 Mon Sep 17 00:00:00 2001 From: Bruno Manuel Santos Saraiva Date: Tue, 8 Jul 2025 10:46:07 +0100 Subject: [PATCH 7/8] version bump, changes to fix issue #132 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 442af95e..41ee8237 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ ] EXTRA_LING_ARGS = [] -VERSION = "1.2.2" # sets version number for whole package +VERSION = "1.2.3" # sets version number for whole package def run_command(command: str) -> str: From c27e19e87811694694b77e934ae3ec1293973932 Mon Sep 17 00:00:00 2001 From: Bruno Manuel Santos Saraiva Date: Tue, 8 Jul 2025 10:50:30 +0100 Subject: [PATCH 8/8] changing default grad_magnification --- src/nanopyx/methods/esrrf/eSRRF_workflow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nanopyx/methods/esrrf/eSRRF_workflow.py b/src/nanopyx/methods/esrrf/eSRRF_workflow.py index 098369bb..51de6986 100644 --- a/src/nanopyx/methods/esrrf/eSRRF_workflow.py +++ b/src/nanopyx/methods/esrrf/eSRRF_workflow.py @@ -12,7 +12,7 @@ def eSRRF( image, magnification: int = 5, - grad_magnification: int = 1, + grad_magnification: int = 2, radius: float = 1.5, sensitivity: float = 1, frames_per_timepoint: int = 0,