IJM.getDataset() crashing MATLAB

Hi Everyone,

I’m currently working on importing a high dimensional (7 channels) czi dataset from ImageJ to MATLAB. Everytime I run the IJM.getDataset(); function MATLAB crashes. Anyone else experiencing this issue?

Hi Alex,
there are may be different reasons for crushing, perhaps you should put here the output as Matlab shows.

MATLAB crash file:C:\Users\al519927\AppData\Local\Temp\matlab_crash_dump.8280-1:

      Access violation detected at Tue Jul 02 11:04:59 2019 -0400

Crash Decoding : Disabled - No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : windows-1252
Deployed : false
Graphics Driver : Unknown hardware
Graphics card 1 : NVIDIA ( 0x10de ) NVIDIA GeForce GTX 1050 Version (2018-3-16)
Graphics card 2 : Intel Corporation ( 0x8086 ) Intel® UHD Graphics 630 Version (2018-8-15)
Java Version : Java 1.8.0_152-b16 with Oracle Corporation Java HotSpot™ 64-Bit Server VM mixed mode
MATLAB Architecture : win64
MATLAB Entitlement ID : 3740494
MATLAB Root : C:\Program Files\MATLAB\R2018b
MATLAB Version : (R2018b)
OpenGL : hardware
Operating System : Microsoft Windows 10 Enterprise
Process ID : 8280
Processor ID : x86 Family 6 Model 158 Stepping 10, GenuineIntel
Session Key : aff80e3d-38c1-44f1-b094-9a39b61cf9f3
Window System : Version 10.0 (Build 16299)

Fault Count: 1

Abnormal termination

Register State (from fault):
RAX = 0000000000000040 RBX = 0000000064e21000
RCX = 0000000ad62a0860 RDX = fffffff6e91e62a0
RSP = 00000000043f8b68 RBP = 0000000000000000
RSI = 0000000088093800 RDI = 0000000000000000

R8 = ffffffff88093800 R9 = 00000010000005c8
R10 = 0000000000000001 R11 = 0000000b4e20d060
R12 = 00000000ed9c0be8 R13 = 00000000fa790480
R14 = 0000000000000000 R15 = 0000000142c227a0

RIP = 000000006edec22a EFL = 00010206

CS = 0033 FS = 0053 GS = 002b

Stack Trace (from fault):
[ 0] 0x000000006edec22a C:\Program Files\MATLAB\R2018b\sys\java\jre\win64\jre\bin\MSVCR100.dll+00246314 memmove+00000714
[ 1] 0x000000006efebe3b C:\Program Files\MATLAB\R2018b\sys\java\jre\win64\jre\bin\server\jvm.dll+01424955 JNI_GetCreatedJavaVMs+00127259
[ 2] 0x00000000fa727df9 bin\win64\nativejmi.dll+00359929 NativeLabCmdWinSetup+00011833
[ 3] 0x00000000fa7276ae bin\win64\nativejmi.dll+00358062 NativeLabCmdWinSetup+00009966
[ 4] 0x00000000fa720bd5 bin\win64\nativejmi.dll+00330709 nativejmi::JmiFEvalIIP::write+00011045
[ 5] 0x00000000fd00a03f bin\win64\iqm.dll+00499775 iqm::BaseFEvalPlugin::execute+00000063
[ 6] 0x00000000fa720a0f bin\win64\nativejmi.dll+00330255 nativejmi::JmiFEvalIIP::write+00010591
[ 7] 0x00000000fa77083a bin\win64\nativejmi.dll+00657466 NativeLabCmdWinSetup+00309370
[ 8] 0x00000000fcffcc07 bin\win64\iqm.dll+00445447 iqm::Iqm::setupIqmFcnPtrs+00076215
[ 9] 0x00000000fcffcc59 bin\win64\iqm.dll+00445529 iqm::Iqm::setupIqmFcnPtrs+00076297
[ 10] 0x00000000fcffca16 bin\win64\iqm.dll+00444950 iqm::Iqm::setupIqmFcnPtrs+00075718
[ 11] 0x00000000fcfde8ce bin\win64\iqm.dll+00321742 iqm::Iqm::deliver+00026750
[ 12] 0x00000000fcfcca67 bin\win64\iqm.dll+00248423 iqm::IqmInputRequestEvent::~IqmInputRequestEvent+00010631
[ 13] 0x0000000012f05fdb bin\win64\mlutil.dll+02842587 cmddistributor::IIPRunNowMessage::deliver+00000027
[ 14] 0x00000000fdedb738 bin\win64\libmwms.dll+01881912 foundation::msg_svc::exchange::MessageQueue::deliver+00000216
[ 15] 0x00000000fdedc750 bin\win64\libmwms.dll+01886032 foundation::msg_svc::exchange::MessageQueue::sendReply+00003568
[ 16] 0x00000000fdec62e0 bin\win64\libmwms.dll+01794784 foundation::msg_svc::exchange::CommunicationErrorEvent::getIsError+00073072
[ 17] 0x00000000fded15fc bin\win64\libmwms.dll+01840636 foundation::msg_svc::exchange::CommunicationErrorEvent::getIsError+00118924
[ 18] 0x00000000fded0b07 bin\win64\libmwms.dll+01837831 foundation::msg_svc::exchange::CommunicationErrorEvent::getIsError+00116119
[ 19] 0x0000000012d81f06 bin\win64\mlutil.dll+01253126 cmddistributor::IIP::EventMgrBypass::operator=+00045686
[ 20] 0x0000000012d5b346 bin\win64\mlutil.dll+01094470 cmddistributor::DebugLoopEvent::serializeExplicit+00018454
[ 21] 0x00000000fa75baa3 bin\win64\nativejmi.dll+00572067 NativeLabCmdWinSetup+00223971
[ 22] 0x00000000fa7556de bin\win64\nativejmi.dll+00546526 NativeLabCmdWinSetup+00198430
[ 23] 0x00000000fa7355cd bin\win64\nativejmi.dll+00415181 NativeLabCmdWinSetup+00067085
[ 24] 0x00000000fa7584cf bin\win64\nativejmi.dll+00558287 NativeLabCmdWinSetup+00210191
[ 25] 0x00000000fa74e3ef bin\win64\nativejmi.dll+00517103 NativeLabCmdWinSetup+00169007
[ 26] 0x000000006fbf81b4 +00000000
[ 27] 0x000000006cb28eb8 +00000000
[ 28] 0x00000000043fac00 +00000000

Maybe a problem with my graphics driver? But IJM.getDataset(); seems to work when I split the channels and import only a single channel.

I have no idea about this problem…
Have you tried to import a simple 2D/3D dataset?
If you are interested in reading czi files to Matlab you can try bioformats for direct reading without Fiji.

You might want to try running MATLAB with a different Java Virtual Machine. I also recommend contacting MathWorks support for this crash analysis.


I think I’ll try out the different Java virtual machine. I’ll report back if I can get full functionality.

So far my best available option has been to split the channels and import to Matlab using IJM.getDataset(); (for the individual channels).
While the full hyperstack isn’t imported it is still more desirable to use this track rather than the bfopen(id); function. My goal is to write a script for automatic thresholding as described in a recent paper, so for now single channel imports suffice.

What happens when you use bfopen?

bfopen() imports the data fine. The only issue I have with it is that the channels aren’t grouped together such that I can easily work with them individually. The only way I can work with my individual channels (16 slices each) is to manually create a plane variable for each slice with respect to that channel and then concatenate them into a 3D array. IJM.getDataset will import the channels (at least individually) so that they are already in that form. And I believe, if I am remembering correctly, bfopen converts the data type to uint8 instead of double (which is the data type of the original czi file).

Have you tried bfGetPlane function of bioformts? As far as I remember, it reads channels individually and you free to arrange them the way you like. I also doubt that there is automatic conversion to uint8, on my experience the data imported the way it is stored.
Are you sure that the original images are in double, normally it would be uint16/unit8.

1 Like

The last part I may be misremembering (about data conversion). bfgetplanedata is what I used to extract individual slices and reconstruct a channel. The indexing of the imported cell for the seven channels is read as 112 slices where 1-7 is Z1 for channels 1-7 then 8-14 is Z2 for those channels etc. Can I use the bfgetpanedata function to extract multiple planes into one 3D array?

would it be something like this?

colChId =1;  % define index of the color channel
Z1 = zeros([height, width, depth], 'uint16');   % allocate space
index = 1; % index of a z-slice
for z=colChId:7:112
    Z1(:,:,index) = bfGetPlane(r, z);  % get slice and allocate to the stack, I may be wrong with height/width dimensions
    index = index + 1;

You might be interested in the Danuser Lab’s object oriented MovieData infrastructure for MATLAB:

Even if you don’t use the class directly it gives nice examples on how to extract the metadata automatically.

In particular, the loadStack function in the base class will help you obtain 3D matrices for each channel easily.


In particular,

       function I = loadImage_(obj, c, t, z, varargin)
            javaIndex =  obj.getReader().getIndex(z - 1, c - 1, t - 1);
            I = bfGetPlane(obj.getReader(), javaIndex + 1);

This uses the getIndex method of FormatReader

1 Like

Nice stuff, Mark!
thank you for sharing

This all sounds promising! I’ll try it out sometime Monday or Tuesday and report back. Thanks for the tips!

1 Like

Mark! Thank you! The Utrack software is working well for me. All the best.

1 Like

@AlexLemus, my pleasure. I’m curious how you ended up using it. I have been considering extracting out some of the core elements into a package with a dedicated namespace so that the code is more modular.

Just to assign credit properly, much of the Reader and BioFormatsReader implementation and design is from @s.besson with inspiration from the OME IFormatReader design, I believe.

Support for the software is currently provided by Qiongjing “Jenny” Zou in the Danuser lab:

1 Like

Proper credit is well deserved. Works like a charm so I’ll keep that in mind. My apologies for the delay in my reply. I’m using it for image segmentation of biofilms. I am working on a best practice for preserving the physical and spatial integrity of multispectrally labeled biofilms. I’m beginning with the principles described for the Biovolume elasticity method (BEM) as described in a recent Nature paper (https://www.nature.com/articles/s41598-018-31012-5).