필터 지우기
필터 지우기

How to bring the (non-struct array object) pixel data into the right format?

조회 수: 1 (최근 30일)
Katharina Hecker
Katharina Hecker 2018년 6월 16일
댓글: Katharina Hecker 2018년 6월 16일
I am trying to bring an image volume (181x299x305 double (=FilteredVolume)) from Matlab to the 3D Slicer (with the MatlabBridge Extension). The size of the voxels are [0.0500 0.0500 0.0500]. The number of slides from which the volume was created are 181.
I have used the code:
load('matrixfilteredvolume.mat');
img.ijkToLpsTransform = [ 0.05 0 0 0; 0 0.05 0 0; 0 0 0.05 0; 0 0 0 1];
img.pixelData=FilteredVolume
cli_imagewrite(img.ijkToLpsTransform.FilteredVolume, img);
--------------------
But now I get the Error:
img =
struct with fields:
ijkToLpsTransform: [4×4 double]
pixelData: [181×299×305 double]
Struct contents reference from a non-struct array object.
Error in (line 19)
cli_imagewrite(img.ijkToLpsTransform.FilteredVolume, img);
Can anybody help me how I should change the structure contents of my matrix to make this code work?
I am working on it quit a long time, so I would be very pleased about any suggestions!

답변 (2개)

Walter Roberson
Walter Roberson 2018년 6월 16일
You construct
img.ijkToLpsTransform = [ 0.05 0 0 0; 0 0.05 0 0; 0 0 0.05 0; 0 0 0 1]
so img.ijkToLpsTransform is a numeric vector.
But then you try
cli_imagewrite(img.ijkToLpsTransform.FilteredVolume, img);
implying that you think img.ijkToLpsTransform is a struct.
Perhaps you wanted
cli_imagewrite(img.FilteredVolume, img);
  댓글 수: 10
Guillaume
Guillaume 2018년 6월 16일
At this point, it's probably easier if you attach to your question the unmodified m file that you're supposed to edit.

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2018년 6월 16일
Try this:
load('matrixfilteredvolume.mat');
% "img" has now been poofed into memory.
img.ijkToLpsTransform = [ 0.05 0 0 0; 0 0.05 0 0; 0 0 0.05 0; 0 0 0 1];
% Assign the pixelFata field to FilteredVolume.
% We KNOW that FilteredVolume already exists because you got past this line.
img.pixelData=FilteredVolume
% Now write out FilteredVolume:
cli_imagewrite(FilteredVolume, img);
I'm not really sure what your function cli_imagewrite() does since you didn't include it but presumably it wants something like FilteredVolume as the first argument and a structure as the second argument.
  댓글 수: 9
Walter Roberson
Walter Roberson 2018년 6월 16일
It appears to me that you need to download https://github.com/PerkLab/SlicerMatlabBridge and make sure that the directories are on your MATLAB path.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by