Extracting a 1D vector from a 3D wave
kpantzas
I've been handling spectral images, which are quite naturally stored in 3D arrays where row = abscissa column = ordinate, and layer = wavelength. I switched to Igor to take advantage of its advanced peak fitting capabilities, but a simple operation eludes me: I can't extract the spectrum at a given [row][column]. This is the syntax I've tried:
Make/D/N=(128,320,400) spim=p+q+r //3D wave storing spectral image
Make/D/N=400 spec //1D wave to contain spectrum
spec = spim[115][53][r] //extract spectrum at row=115, column=53
Make/D/N=400 spec //1D wave to contain spectrum
spec = spim[115][53][r] //extract spectrum at row=115, column=53
I expect this snippet to give a vector that contains all integers from 168 to 567. But it doesn't work. Spec is a 1D vector containing only 168.
Display spim[115][53][r]
works fine though, which only adds to my confusion...The underlying idea is to iteratively pass each spectrum of the spectral image to MP2AutoMPFit() for peak identification and fitting.
Any suggestions?
Display
,r
is the the layer of the wave being passed to the copmmandIn a wave assignment,
r
would refer to the (inexistent) layers dimension of the left-hand side wave in the assignment.Thus, the correct wave assignment would be:
Make/D/N=400 spec //1D wave to contain spectrum
spec = spim[115][53][p] //extract spectrum at row=115, column=53
And that worked correctly.
Sorry for the decidedly pointless post!
October 25, 2013 at 06:49 am - Permalink
October 25, 2013 at 07:58 am - Permalink
Here's a question related to using MatrixOP with 3D waves:
I want to sum the columns(rows/beams) using sumColumns(Rows/Beams)
This always returns a 3D wave of size nRows x 1 x nBeams (1 x nColumns x nBeams / nRows x nColumns x 1). I'd like to get rid of the singleton dimension. I tried playing around with
Redimension
, but have had no luck yet.Any suggestions?
October 25, 2013 at 08:48 am - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
October 25, 2013 at 09:04 am - Permalink
Thought there might be some equivalent to MATLAB's squeeze function.
Thanks for the reply nonetheless!
October 25, 2013 at 09:20 am - Permalink