フィルターのクリア

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

2 ビュー (過去 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.
Katharina Hecker
Katharina Hecker 2018 年 6 月 16 日
ok, thanks a lot for your help!!!

サインインしてコメントする。


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.
Katharina Hecker
Katharina Hecker 2018 年 6 月 16 日
Thanks I will try it out

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by