I'm trying to adapt this to use to unwrap along arbitrary dimensions in an array and having a bit of trouble wrapping my head around how to manage it.
I can compute the phase difference between adjacent slices using slicedim, and computing the new phase value isn't hard, but i need to assign the result back to the array, basically treating slicedim as a view (which doesn't work). How should I do this?
Here's what I have so far (with the failing assignment into the slicedim):
function unwrap!(m::Array, dim::Integer=ndims(m))
if size(m, dim) < 2
return m
end
for i = 2:size(m, dim)
d = slicedim(m, dim, i) - slicedim(m, dim, i-1)
slicedim(m, dim, i) -= floor((d+pi) / (2pi)) * 2pi
end
return m
end