How to convert a time-lapse (series of masked surfaces) to a binary matrix in MATLAB?Convert a matrix of type double to image in MatlabTime series classification MATLABHow to make a video from a 3d matrix in matlabHow to store a matrix-valued time-series in R?Convert matlab code into python for matrix creationConverting time series to data frame, matrix, or tableC#: Converting binary to axb matrixAdd a element to a 2D time series in MatlabCumulative cost matrix path in dtw converted into coordinates/applied to time seriesHow to identify recurring patterns in time-series data in Matlab
Why did Khan ask Admiral James T. Kirk about Project Genesis?
Handling Disruptive Student on the Autistic Spectrum
What is the difference between Major and Minor Bug?
How do I, an introvert, communicate to my friend and only colleague, an extrovert, that I want to spend my scheduled breaks without them?
French abbreviation for comparing two items ("vs")
Why is there so little discussion / research on the philosophy of precision?
Who was president of the USA?
“T” in subscript in formulas
"Sorry to bother you" in an email?
Sum ergo cogito?
Showing that the limit of non-eigenvector goes to infinity
Why is the UK so keen to remove the "backstop" when their leadership seems to think that no border will be needed in Northern Ireland?
Is gzip atomic?
How do the Etherealness and Banishment spells interact?
Why is 7 Bd3 in the Cambridge Springs QGD more often met with 7...Ne4 than 7...dxc4?
Did the British navy fail to take into account the ballistics correction due to Coriolis force during WW1 Falkland Islands battle?
Numbers Decrease while Letters Increase
How do I make my image comply with the requirements of this photography competition?
Is there any practical application for performing a double Fourier transform? ...or an inverse Fourier transform on a time-domain input?
Network helper class with retry logic on failure
How to determine car loan length as a function of how long I plan to keep a car
Which cells to pick to get a pure sample of DNA without precise equipment?
Problem when including a foreach loop
Arduino oscilloscope voltage divider design
How to convert a time-lapse (series of masked surfaces) to a binary matrix in MATLAB?
Convert a matrix of type double to image in MatlabTime series classification MATLABHow to make a video from a 3d matrix in matlabHow to store a matrix-valued time-series in R?Convert matlab code into python for matrix creationConverting time series to data frame, matrix, or tableC#: Converting binary to axb matrixAdd a element to a 2D time series in MatlabCumulative cost matrix path in dtw converted into coordinates/applied to time seriesHow to identify recurring patterns in time-series data in Matlab
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I study immune cells with the imaging software Imaris, which allows the masking of the surface of cells in a time-lapse experiment, and links each masked surface from one time frame to another, so that they can be tracked.
I work with 2D data sets and, for each time frame and each surface object (cell), I need to extract several 2D parameters (perimeter, major axis length, area), so that I can monitor cell shape variation over time. Unfortunately, Imaris gives several 3D parameters (volume of detected particles etc), but no 2D parameter.
Imaris is built so that data can be exported to Matlab, and I have been told it should be possible to use Matlab to extract these 2D parameters.
My objective is therefore to export my masked 2D surfaces (as a time-series) to Matlab, and extract the 2D parameters mentioned above.
With help from the Imaris support team I was able to correctly link Matlab and Imaris, import my data set, extract the mask data, and convert it to a binary matrix. With the provided code, this could only done for one time frame, however (out of 61). Still, I was able to convert this time frame (one image) to a binary matrix, and in turn the binary matrix to a binary image, from which I could extract the parameters I need (using the regionprops function).
My problem lies in doing this with the whole time series, which requires the original code to be modified. While I think I have made some progress, I believe I am stuck. Hence this question.
As you will see in the code below, I modified the "vindexT = 0" which selected only one time frame to "for vIndexT = 0:vSizeT" (where vSizeT is the maximum number of time frames, 61) which I believed would prompt Matlab to to do the same operation for all time frames. When I put the "end" operator just after the code extracting the mask data from Imaris, I do not get any error message. Which I hope means all the mask data had properly been imported (but I don't know how to verify that). However, when I run the next part of the code which should convert the mask data ("vMask") to a binary matrix, I get the error message I have pasted below.
Alternatively, I have tried to place the "end" operator after the code to convert the mask to a matrix (instead of having two loops I then only have one), but I got the same error message.
Here is the original code I was sent: this one allowed me to properly process one time frame:
%% %Get a Copy of the Dataset
vImarisDataSet = vImarisApplication.GetDataSet.Clone;
%%
% Get Surpass Surfaces Object - Please ensure that it is selected in the
% Surpass Tree
vImarisObject = vImarisApplication.GetSurpassSelection;
%% %Convert the Object into the correct Data Type
vImarisObject = vImarisApplication.GetFactory.ToSurfaces(vImarisObject);
%% % Get the data dimensions
vDataMin = [vImarisDataSet.GetExtendMinX, vImarisDataSet.GetExtendMinY, vImarisDataSet.GetExtendMinZ];
vDataMax = [vImarisDataSet.GetExtendMaxX, vImarisDataSet.GetExtendMaxY, vImarisDataSet.GetExtendMaxZ];
vDataSize = [vImarisDataSet.GetSizeX, vImarisDataSet.GetSizeY, vImarisDataSet.GetSizeZ];
%%
% Create a new channel where the result will be sent
vNumberOfChannels = vImarisDataSet.GetSizeC;
vImarisDataSet.SetSizeC(vNumberOfChannels + 1);
vImarisDataSet.SetChannelName(vNumberOfChannels,['Surface Mask ', char(vImarisObject.GetName)]);
vImarisDataSet.SetChannelColorRGBA(vNumberOfChannels, 255*256*256+255*256+255);
%% %Get the Size of the Time Dimension
vDataSize = [vDataSize, vImarisDataSet.GetSizeT];
%% % Here only the first time point is considered to show the principle
vIndexT = 0;
%% %extract the Mask Data from Imaris
vMaskDataSet = vImarisObject.GetMask( ...
vDataMin(1), vDataMin(2), vDataMin(3), ...
vDataMax(1), vDataMax(2), vDataMax(3), ...
vDataSize(1), vDataSize(2), vDataSize(3), vIndexT);
%% %Convert the Imaris data into an Matlab Matrix
vMask = GetDataVolume(vMaskDataSet, 0, 0);
Here is what I have tried in order to import and convert the entire time series:
%%
% Create a new channel where the result will be sent
vNumberOfChannels = vImarisDataSet.GetSizeC;
vImarisDataSet.SetSizeC(vNumberOfChannels + 1);
vImarisDataSet.SetChannelName(vNumberOfChannels,['Surface Mask ', char(vImarisObject.GetName)]);
vImarisDataSet.SetChannelColorRGBA(vNumberOfChannels, 255*256*256+255*256+255);
aSizeX = vImarisDataSet.GetSizeX;
aSizeY = vImarisDataSet.GetSizeY;
vSizeT = vImarisDataSet.GetSizeT;
%% %Get the Size of the Time Dimension
vDataSize = [vDataSize, vImarisDataSet.GetSizeT];
%% % Here only the first time point is considered to show the principle
vSizeT = vImarisDataSet.GetSizeT;
for vIndexT = 1:vSizeT-1
%% %extract the Mask Data from Imaris
vMaskDataSet = vImarisObject.GetMask( ...
vDataMin(1), vDataMin(2), vDataMin(3), ...
vDataMax(1), vDataMax(2), vDataMax(3), ...
vDataSize(1), vDataSize(2), vDataSize(3), vIndexT);
end
%% %Convert the Imaris data into an Matlab Matrix
for vIndexT = 1:vSizeT-1
vMask = GetDataVolume(vMaskDataSet, 0, vIndexT);
end
And here is the error I get when I run the modified code:
Error using GetDataVolume (line 23)
Java exception occurred:
Imaris.Error
mType = "bpIllegalRangeException"
mDescription = "Error in bpImageT<Element>::CopyFromChannel"
mLocation = "bpIceDataSet::GetDataSubVolumeAs1DArrayBytes"
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at IceInternal.BasicStream.createUserException(BasicStream.java:2779)
at IceInternal.BasicStream.access$300(BasicStream.java:14)
at IceInternal.BasicStream$EncapsDecoder10.throwException(BasicStream.java:3298)
at IceInternal.BasicStream.throwException(BasicStream.java:2291)
at IceInternal.OutgoingAsync.throwUserException(OutgoingAsync.java:399)
at Imaris.IDataSetPrxHelper.end_GetDataSubVolumeAs1DArrayBytes(IDataSetPrxHelper.java:4248)
at Imaris.IDataSetPrxHelper.GetDataSubVolumeAs1DArrayBytes(IDataSetPrxHelper.java:4078)
at Imaris.IDataSetPrxHelper.GetDataSubVolumeAs1DArrayBytes(IDataSetPrxHelper.java:4065)
Error in TestMask (line 52)
vMask = GetDataVolume(vMaskDataSet, 0, vIndexT);
If the code runs correctly I expect it will return a time series made of 61 binary images (times frames). From this I would then extract 2D statistics for each surface, in each time frame.
I know you've heard that before but I'm very new to this and my knowledge of Matlab being very limited, I think it is likely the answer is not far off, but I just can't see it.
If you think I am simply going at it the wrong way, and that there may be a much easier solution to my problem, your suggestion would be greatly appreciated too!
Best wishes,
Florian
image matlab matrix binary time-series
add a comment |
I study immune cells with the imaging software Imaris, which allows the masking of the surface of cells in a time-lapse experiment, and links each masked surface from one time frame to another, so that they can be tracked.
I work with 2D data sets and, for each time frame and each surface object (cell), I need to extract several 2D parameters (perimeter, major axis length, area), so that I can monitor cell shape variation over time. Unfortunately, Imaris gives several 3D parameters (volume of detected particles etc), but no 2D parameter.
Imaris is built so that data can be exported to Matlab, and I have been told it should be possible to use Matlab to extract these 2D parameters.
My objective is therefore to export my masked 2D surfaces (as a time-series) to Matlab, and extract the 2D parameters mentioned above.
With help from the Imaris support team I was able to correctly link Matlab and Imaris, import my data set, extract the mask data, and convert it to a binary matrix. With the provided code, this could only done for one time frame, however (out of 61). Still, I was able to convert this time frame (one image) to a binary matrix, and in turn the binary matrix to a binary image, from which I could extract the parameters I need (using the regionprops function).
My problem lies in doing this with the whole time series, which requires the original code to be modified. While I think I have made some progress, I believe I am stuck. Hence this question.
As you will see in the code below, I modified the "vindexT = 0" which selected only one time frame to "for vIndexT = 0:vSizeT" (where vSizeT is the maximum number of time frames, 61) which I believed would prompt Matlab to to do the same operation for all time frames. When I put the "end" operator just after the code extracting the mask data from Imaris, I do not get any error message. Which I hope means all the mask data had properly been imported (but I don't know how to verify that). However, when I run the next part of the code which should convert the mask data ("vMask") to a binary matrix, I get the error message I have pasted below.
Alternatively, I have tried to place the "end" operator after the code to convert the mask to a matrix (instead of having two loops I then only have one), but I got the same error message.
Here is the original code I was sent: this one allowed me to properly process one time frame:
%% %Get a Copy of the Dataset
vImarisDataSet = vImarisApplication.GetDataSet.Clone;
%%
% Get Surpass Surfaces Object - Please ensure that it is selected in the
% Surpass Tree
vImarisObject = vImarisApplication.GetSurpassSelection;
%% %Convert the Object into the correct Data Type
vImarisObject = vImarisApplication.GetFactory.ToSurfaces(vImarisObject);
%% % Get the data dimensions
vDataMin = [vImarisDataSet.GetExtendMinX, vImarisDataSet.GetExtendMinY, vImarisDataSet.GetExtendMinZ];
vDataMax = [vImarisDataSet.GetExtendMaxX, vImarisDataSet.GetExtendMaxY, vImarisDataSet.GetExtendMaxZ];
vDataSize = [vImarisDataSet.GetSizeX, vImarisDataSet.GetSizeY, vImarisDataSet.GetSizeZ];
%%
% Create a new channel where the result will be sent
vNumberOfChannels = vImarisDataSet.GetSizeC;
vImarisDataSet.SetSizeC(vNumberOfChannels + 1);
vImarisDataSet.SetChannelName(vNumberOfChannels,['Surface Mask ', char(vImarisObject.GetName)]);
vImarisDataSet.SetChannelColorRGBA(vNumberOfChannels, 255*256*256+255*256+255);
%% %Get the Size of the Time Dimension
vDataSize = [vDataSize, vImarisDataSet.GetSizeT];
%% % Here only the first time point is considered to show the principle
vIndexT = 0;
%% %extract the Mask Data from Imaris
vMaskDataSet = vImarisObject.GetMask( ...
vDataMin(1), vDataMin(2), vDataMin(3), ...
vDataMax(1), vDataMax(2), vDataMax(3), ...
vDataSize(1), vDataSize(2), vDataSize(3), vIndexT);
%% %Convert the Imaris data into an Matlab Matrix
vMask = GetDataVolume(vMaskDataSet, 0, 0);
Here is what I have tried in order to import and convert the entire time series:
%%
% Create a new channel where the result will be sent
vNumberOfChannels = vImarisDataSet.GetSizeC;
vImarisDataSet.SetSizeC(vNumberOfChannels + 1);
vImarisDataSet.SetChannelName(vNumberOfChannels,['Surface Mask ', char(vImarisObject.GetName)]);
vImarisDataSet.SetChannelColorRGBA(vNumberOfChannels, 255*256*256+255*256+255);
aSizeX = vImarisDataSet.GetSizeX;
aSizeY = vImarisDataSet.GetSizeY;
vSizeT = vImarisDataSet.GetSizeT;
%% %Get the Size of the Time Dimension
vDataSize = [vDataSize, vImarisDataSet.GetSizeT];
%% % Here only the first time point is considered to show the principle
vSizeT = vImarisDataSet.GetSizeT;
for vIndexT = 1:vSizeT-1
%% %extract the Mask Data from Imaris
vMaskDataSet = vImarisObject.GetMask( ...
vDataMin(1), vDataMin(2), vDataMin(3), ...
vDataMax(1), vDataMax(2), vDataMax(3), ...
vDataSize(1), vDataSize(2), vDataSize(3), vIndexT);
end
%% %Convert the Imaris data into an Matlab Matrix
for vIndexT = 1:vSizeT-1
vMask = GetDataVolume(vMaskDataSet, 0, vIndexT);
end
And here is the error I get when I run the modified code:
Error using GetDataVolume (line 23)
Java exception occurred:
Imaris.Error
mType = "bpIllegalRangeException"
mDescription = "Error in bpImageT<Element>::CopyFromChannel"
mLocation = "bpIceDataSet::GetDataSubVolumeAs1DArrayBytes"
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at IceInternal.BasicStream.createUserException(BasicStream.java:2779)
at IceInternal.BasicStream.access$300(BasicStream.java:14)
at IceInternal.BasicStream$EncapsDecoder10.throwException(BasicStream.java:3298)
at IceInternal.BasicStream.throwException(BasicStream.java:2291)
at IceInternal.OutgoingAsync.throwUserException(OutgoingAsync.java:399)
at Imaris.IDataSetPrxHelper.end_GetDataSubVolumeAs1DArrayBytes(IDataSetPrxHelper.java:4248)
at Imaris.IDataSetPrxHelper.GetDataSubVolumeAs1DArrayBytes(IDataSetPrxHelper.java:4078)
at Imaris.IDataSetPrxHelper.GetDataSubVolumeAs1DArrayBytes(IDataSetPrxHelper.java:4065)
Error in TestMask (line 52)
vMask = GetDataVolume(vMaskDataSet, 0, vIndexT);
If the code runs correctly I expect it will return a time series made of 61 binary images (times frames). From this I would then extract 2D statistics for each surface, in each time frame.
I know you've heard that before but I'm very new to this and my knowledge of Matlab being very limited, I think it is likely the answer is not far off, but I just can't see it.
If you think I am simply going at it the wrong way, and that there may be a much easier solution to my problem, your suggestion would be greatly appreciated too!
Best wishes,
Florian
image matlab matrix binary time-series
add a comment |
I study immune cells with the imaging software Imaris, which allows the masking of the surface of cells in a time-lapse experiment, and links each masked surface from one time frame to another, so that they can be tracked.
I work with 2D data sets and, for each time frame and each surface object (cell), I need to extract several 2D parameters (perimeter, major axis length, area), so that I can monitor cell shape variation over time. Unfortunately, Imaris gives several 3D parameters (volume of detected particles etc), but no 2D parameter.
Imaris is built so that data can be exported to Matlab, and I have been told it should be possible to use Matlab to extract these 2D parameters.
My objective is therefore to export my masked 2D surfaces (as a time-series) to Matlab, and extract the 2D parameters mentioned above.
With help from the Imaris support team I was able to correctly link Matlab and Imaris, import my data set, extract the mask data, and convert it to a binary matrix. With the provided code, this could only done for one time frame, however (out of 61). Still, I was able to convert this time frame (one image) to a binary matrix, and in turn the binary matrix to a binary image, from which I could extract the parameters I need (using the regionprops function).
My problem lies in doing this with the whole time series, which requires the original code to be modified. While I think I have made some progress, I believe I am stuck. Hence this question.
As you will see in the code below, I modified the "vindexT = 0" which selected only one time frame to "for vIndexT = 0:vSizeT" (where vSizeT is the maximum number of time frames, 61) which I believed would prompt Matlab to to do the same operation for all time frames. When I put the "end" operator just after the code extracting the mask data from Imaris, I do not get any error message. Which I hope means all the mask data had properly been imported (but I don't know how to verify that). However, when I run the next part of the code which should convert the mask data ("vMask") to a binary matrix, I get the error message I have pasted below.
Alternatively, I have tried to place the "end" operator after the code to convert the mask to a matrix (instead of having two loops I then only have one), but I got the same error message.
Here is the original code I was sent: this one allowed me to properly process one time frame:
%% %Get a Copy of the Dataset
vImarisDataSet = vImarisApplication.GetDataSet.Clone;
%%
% Get Surpass Surfaces Object - Please ensure that it is selected in the
% Surpass Tree
vImarisObject = vImarisApplication.GetSurpassSelection;
%% %Convert the Object into the correct Data Type
vImarisObject = vImarisApplication.GetFactory.ToSurfaces(vImarisObject);
%% % Get the data dimensions
vDataMin = [vImarisDataSet.GetExtendMinX, vImarisDataSet.GetExtendMinY, vImarisDataSet.GetExtendMinZ];
vDataMax = [vImarisDataSet.GetExtendMaxX, vImarisDataSet.GetExtendMaxY, vImarisDataSet.GetExtendMaxZ];
vDataSize = [vImarisDataSet.GetSizeX, vImarisDataSet.GetSizeY, vImarisDataSet.GetSizeZ];
%%
% Create a new channel where the result will be sent
vNumberOfChannels = vImarisDataSet.GetSizeC;
vImarisDataSet.SetSizeC(vNumberOfChannels + 1);
vImarisDataSet.SetChannelName(vNumberOfChannels,['Surface Mask ', char(vImarisObject.GetName)]);
vImarisDataSet.SetChannelColorRGBA(vNumberOfChannels, 255*256*256+255*256+255);
%% %Get the Size of the Time Dimension
vDataSize = [vDataSize, vImarisDataSet.GetSizeT];
%% % Here only the first time point is considered to show the principle
vIndexT = 0;
%% %extract the Mask Data from Imaris
vMaskDataSet = vImarisObject.GetMask( ...
vDataMin(1), vDataMin(2), vDataMin(3), ...
vDataMax(1), vDataMax(2), vDataMax(3), ...
vDataSize(1), vDataSize(2), vDataSize(3), vIndexT);
%% %Convert the Imaris data into an Matlab Matrix
vMask = GetDataVolume(vMaskDataSet, 0, 0);
Here is what I have tried in order to import and convert the entire time series:
%%
% Create a new channel where the result will be sent
vNumberOfChannels = vImarisDataSet.GetSizeC;
vImarisDataSet.SetSizeC(vNumberOfChannels + 1);
vImarisDataSet.SetChannelName(vNumberOfChannels,['Surface Mask ', char(vImarisObject.GetName)]);
vImarisDataSet.SetChannelColorRGBA(vNumberOfChannels, 255*256*256+255*256+255);
aSizeX = vImarisDataSet.GetSizeX;
aSizeY = vImarisDataSet.GetSizeY;
vSizeT = vImarisDataSet.GetSizeT;
%% %Get the Size of the Time Dimension
vDataSize = [vDataSize, vImarisDataSet.GetSizeT];
%% % Here only the first time point is considered to show the principle
vSizeT = vImarisDataSet.GetSizeT;
for vIndexT = 1:vSizeT-1
%% %extract the Mask Data from Imaris
vMaskDataSet = vImarisObject.GetMask( ...
vDataMin(1), vDataMin(2), vDataMin(3), ...
vDataMax(1), vDataMax(2), vDataMax(3), ...
vDataSize(1), vDataSize(2), vDataSize(3), vIndexT);
end
%% %Convert the Imaris data into an Matlab Matrix
for vIndexT = 1:vSizeT-1
vMask = GetDataVolume(vMaskDataSet, 0, vIndexT);
end
And here is the error I get when I run the modified code:
Error using GetDataVolume (line 23)
Java exception occurred:
Imaris.Error
mType = "bpIllegalRangeException"
mDescription = "Error in bpImageT<Element>::CopyFromChannel"
mLocation = "bpIceDataSet::GetDataSubVolumeAs1DArrayBytes"
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at IceInternal.BasicStream.createUserException(BasicStream.java:2779)
at IceInternal.BasicStream.access$300(BasicStream.java:14)
at IceInternal.BasicStream$EncapsDecoder10.throwException(BasicStream.java:3298)
at IceInternal.BasicStream.throwException(BasicStream.java:2291)
at IceInternal.OutgoingAsync.throwUserException(OutgoingAsync.java:399)
at Imaris.IDataSetPrxHelper.end_GetDataSubVolumeAs1DArrayBytes(IDataSetPrxHelper.java:4248)
at Imaris.IDataSetPrxHelper.GetDataSubVolumeAs1DArrayBytes(IDataSetPrxHelper.java:4078)
at Imaris.IDataSetPrxHelper.GetDataSubVolumeAs1DArrayBytes(IDataSetPrxHelper.java:4065)
Error in TestMask (line 52)
vMask = GetDataVolume(vMaskDataSet, 0, vIndexT);
If the code runs correctly I expect it will return a time series made of 61 binary images (times frames). From this I would then extract 2D statistics for each surface, in each time frame.
I know you've heard that before but I'm very new to this and my knowledge of Matlab being very limited, I think it is likely the answer is not far off, but I just can't see it.
If you think I am simply going at it the wrong way, and that there may be a much easier solution to my problem, your suggestion would be greatly appreciated too!
Best wishes,
Florian
image matlab matrix binary time-series
I study immune cells with the imaging software Imaris, which allows the masking of the surface of cells in a time-lapse experiment, and links each masked surface from one time frame to another, so that they can be tracked.
I work with 2D data sets and, for each time frame and each surface object (cell), I need to extract several 2D parameters (perimeter, major axis length, area), so that I can monitor cell shape variation over time. Unfortunately, Imaris gives several 3D parameters (volume of detected particles etc), but no 2D parameter.
Imaris is built so that data can be exported to Matlab, and I have been told it should be possible to use Matlab to extract these 2D parameters.
My objective is therefore to export my masked 2D surfaces (as a time-series) to Matlab, and extract the 2D parameters mentioned above.
With help from the Imaris support team I was able to correctly link Matlab and Imaris, import my data set, extract the mask data, and convert it to a binary matrix. With the provided code, this could only done for one time frame, however (out of 61). Still, I was able to convert this time frame (one image) to a binary matrix, and in turn the binary matrix to a binary image, from which I could extract the parameters I need (using the regionprops function).
My problem lies in doing this with the whole time series, which requires the original code to be modified. While I think I have made some progress, I believe I am stuck. Hence this question.
As you will see in the code below, I modified the "vindexT = 0" which selected only one time frame to "for vIndexT = 0:vSizeT" (where vSizeT is the maximum number of time frames, 61) which I believed would prompt Matlab to to do the same operation for all time frames. When I put the "end" operator just after the code extracting the mask data from Imaris, I do not get any error message. Which I hope means all the mask data had properly been imported (but I don't know how to verify that). However, when I run the next part of the code which should convert the mask data ("vMask") to a binary matrix, I get the error message I have pasted below.
Alternatively, I have tried to place the "end" operator after the code to convert the mask to a matrix (instead of having two loops I then only have one), but I got the same error message.
Here is the original code I was sent: this one allowed me to properly process one time frame:
%% %Get a Copy of the Dataset
vImarisDataSet = vImarisApplication.GetDataSet.Clone;
%%
% Get Surpass Surfaces Object - Please ensure that it is selected in the
% Surpass Tree
vImarisObject = vImarisApplication.GetSurpassSelection;
%% %Convert the Object into the correct Data Type
vImarisObject = vImarisApplication.GetFactory.ToSurfaces(vImarisObject);
%% % Get the data dimensions
vDataMin = [vImarisDataSet.GetExtendMinX, vImarisDataSet.GetExtendMinY, vImarisDataSet.GetExtendMinZ];
vDataMax = [vImarisDataSet.GetExtendMaxX, vImarisDataSet.GetExtendMaxY, vImarisDataSet.GetExtendMaxZ];
vDataSize = [vImarisDataSet.GetSizeX, vImarisDataSet.GetSizeY, vImarisDataSet.GetSizeZ];
%%
% Create a new channel where the result will be sent
vNumberOfChannels = vImarisDataSet.GetSizeC;
vImarisDataSet.SetSizeC(vNumberOfChannels + 1);
vImarisDataSet.SetChannelName(vNumberOfChannels,['Surface Mask ', char(vImarisObject.GetName)]);
vImarisDataSet.SetChannelColorRGBA(vNumberOfChannels, 255*256*256+255*256+255);
%% %Get the Size of the Time Dimension
vDataSize = [vDataSize, vImarisDataSet.GetSizeT];
%% % Here only the first time point is considered to show the principle
vIndexT = 0;
%% %extract the Mask Data from Imaris
vMaskDataSet = vImarisObject.GetMask( ...
vDataMin(1), vDataMin(2), vDataMin(3), ...
vDataMax(1), vDataMax(2), vDataMax(3), ...
vDataSize(1), vDataSize(2), vDataSize(3), vIndexT);
%% %Convert the Imaris data into an Matlab Matrix
vMask = GetDataVolume(vMaskDataSet, 0, 0);
Here is what I have tried in order to import and convert the entire time series:
%%
% Create a new channel where the result will be sent
vNumberOfChannels = vImarisDataSet.GetSizeC;
vImarisDataSet.SetSizeC(vNumberOfChannels + 1);
vImarisDataSet.SetChannelName(vNumberOfChannels,['Surface Mask ', char(vImarisObject.GetName)]);
vImarisDataSet.SetChannelColorRGBA(vNumberOfChannels, 255*256*256+255*256+255);
aSizeX = vImarisDataSet.GetSizeX;
aSizeY = vImarisDataSet.GetSizeY;
vSizeT = vImarisDataSet.GetSizeT;
%% %Get the Size of the Time Dimension
vDataSize = [vDataSize, vImarisDataSet.GetSizeT];
%% % Here only the first time point is considered to show the principle
vSizeT = vImarisDataSet.GetSizeT;
for vIndexT = 1:vSizeT-1
%% %extract the Mask Data from Imaris
vMaskDataSet = vImarisObject.GetMask( ...
vDataMin(1), vDataMin(2), vDataMin(3), ...
vDataMax(1), vDataMax(2), vDataMax(3), ...
vDataSize(1), vDataSize(2), vDataSize(3), vIndexT);
end
%% %Convert the Imaris data into an Matlab Matrix
for vIndexT = 1:vSizeT-1
vMask = GetDataVolume(vMaskDataSet, 0, vIndexT);
end
And here is the error I get when I run the modified code:
Error using GetDataVolume (line 23)
Java exception occurred:
Imaris.Error
mType = "bpIllegalRangeException"
mDescription = "Error in bpImageT<Element>::CopyFromChannel"
mLocation = "bpIceDataSet::GetDataSubVolumeAs1DArrayBytes"
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at IceInternal.BasicStream.createUserException(BasicStream.java:2779)
at IceInternal.BasicStream.access$300(BasicStream.java:14)
at IceInternal.BasicStream$EncapsDecoder10.throwException(BasicStream.java:3298)
at IceInternal.BasicStream.throwException(BasicStream.java:2291)
at IceInternal.OutgoingAsync.throwUserException(OutgoingAsync.java:399)
at Imaris.IDataSetPrxHelper.end_GetDataSubVolumeAs1DArrayBytes(IDataSetPrxHelper.java:4248)
at Imaris.IDataSetPrxHelper.GetDataSubVolumeAs1DArrayBytes(IDataSetPrxHelper.java:4078)
at Imaris.IDataSetPrxHelper.GetDataSubVolumeAs1DArrayBytes(IDataSetPrxHelper.java:4065)
Error in TestMask (line 52)
vMask = GetDataVolume(vMaskDataSet, 0, vIndexT);
If the code runs correctly I expect it will return a time series made of 61 binary images (times frames). From this I would then extract 2D statistics for each surface, in each time frame.
I know you've heard that before but I'm very new to this and my knowledge of Matlab being very limited, I think it is likely the answer is not far off, but I just can't see it.
If you think I am simply going at it the wrong way, and that there may be a much easier solution to my problem, your suggestion would be greatly appreciated too!
Best wishes,
Florian
image matlab matrix binary time-series
image matlab matrix binary time-series
edited Mar 27 at 17:52
Florian
asked Mar 27 at 17:44
FlorianFlorian
63 bronze badges
63 bronze badges
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55383530%2fhow-to-convert-a-time-lapse-series-of-masked-surfaces-to-a-binary-matrix-in-ma%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55383530%2fhow-to-convert-a-time-lapse-series-of-masked-surfaces-to-a-binary-matrix-in-ma%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown