Skip to main content

MriCompressedSensing

Struct MriCompressedSensing 

Source
pub struct MriCompressedSensing {
    pub n: usize,
    pub m: usize,
}
Expand description

Compressed sensing reconstruction for MRI-like k-space data.

In MRI, measurements are taken in Fourier (k-space) domain. This module provides a simplified 1-D model: the signal is sparse in the DCT domain, and k-space samples are random Fourier measurements.

Fields§

§n: usize

Signal length.

§m: usize

Number of k-space samples (measurements).

Implementations§

Source§

impl MriCompressedSensing

Source

pub fn new(n: usize, m: usize) -> Self

Create an MRI-CS reconstruction problem for a signal of length n with m k-space measurements.

Source

pub fn sample_kspace_indices(&self) -> Vec<usize>

Generate random k-space sampling indices in [0, n).

Returns m unique indices (or repeating if m > n).

Source

pub fn build_measurement_matrix( &self, kspace_indices: &[usize], ) -> Vec<Vec<f64>>

Build a partial Fourier (cosine) measurement matrix from k-space indices.

Row i corresponds to k-space sample k_i; entry (i, j) is cos(2π k_i j / n) / sqrt(m).

Source

pub fn reconstruct_fista( &self, measurements: &[f64], kspace_indices: &[usize], lambda: f64, max_iter: usize, ) -> Vec<f64>

Reconstruct a signal from k-space measurements using FISTA.

  • measurements — observed k-space values
  • kspace_indices — which k-space lines were sampled
  • lambda — sparsity regularisation
  • max_iter — number of FISTA iterations

Returns the reconstructed signal.

Source

pub fn psnr(original: &[f64], reconstructed: &[f64], max_val: f64) -> f64

Compute the peak signal-to-noise ratio (PSNR) between two signals.

PSNR = 20 * log10(max_val / RMSE)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.