⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 avw_img_read_4d.html

📁 mri_toolbox是一个工具用来MRI. 来自于SourceForge, 我上传这个软件,希望能结识对医疗软件感兴趣的兄弟.
💻 HTML
📖 第 1 页 / 共 4 页
字号:
0308     0309     avw.img = zeros(PixelDim,RowDim,SliceDim);0310     0311     n = 1;0312     x = 1:PixelDim;0313     <span class="keyword">for</span> z = 1:SliceDim,0314       <span class="keyword">for</span> y = 1:RowDim,0315         <span class="comment">% load Y row of X values into Z slice avw.img</span>0316         avw.img(x,y,z) = tmp(n:n+(PixelDim-1));0317         n = n + PixelDim;0318       <span class="keyword">end</span>0319     <span class="keyword">end</span>0320     0321     <span class="comment">% no need to rearrange avw.hdr.dime.dim or avw.hdr.dime.pixdim</span>0322     0323     0324   <span class="keyword">case</span> 1, <span class="comment">% coronal unflipped</span>0325     0326     <span class="comment">% orient = 1:  The primary orientation of the data on disk is in the coronal</span>0327     <span class="comment">% plane relative to the object scanned.  Most commonly, the fastest moving</span>0328     <span class="comment">% index through the voxels that are part of this coronal image would span the</span>0329     <span class="comment">% right-&gt;left extent of the structure imaged, with the next fastest moving</span>0330     <span class="comment">% index spanning the inferior-&gt;superior extent of the structure.  This 'orient'</span>0331     <span class="comment">% flag would indicate to Analyze that this data should be placed in the X-Z</span>0332     <span class="comment">% plane of the 3D Analyze Coordinate System, with the Y dimension being the</span>0333     <span class="comment">% slice direction.</span>0334     0335     <span class="comment">% For the 'coronal unflipped' type, the voxels are stored with</span>0336     <span class="comment">% Pixels in 'x' axis (varies fastest) - from patient right to left</span>0337     <span class="comment">% Rows in   'z' axis                  - from patient inferior to superior</span>0338     <span class="comment">% Slices in 'y' axis                  - from patient posterior to anterior</span>0339     0340     fprintf(<span class="string">'...reading coronal unflipped orientation\n'</span>);0341     0342     avw.img = zeros(PixelDim,SliceDim,RowDim);0343     0344     n = 1;0345     x = 1:PixelDim;0346     <span class="keyword">for</span> y = 1:SliceDim,0347       <span class="keyword">for</span> z = 1:RowDim,0348         <span class="comment">% load Z row of X values into Y slice avw.img</span>0349         avw.img(x,y,z) = tmp(n:n+(PixelDim-1));0350         n = n + PixelDim;0351       <span class="keyword">end</span>0352     <span class="keyword">end</span>0353     0354     <span class="comment">% rearrange avw.hdr.dime.dim or avw.hdr.dime.pixdim</span>0355     avw.hdr.dime.dim(2:4) = int16([PixelDim,SliceDim,RowDim]);0356     avw.hdr.dime.pixdim(2:4) = single([PixelSz,SliceSz,RowSz]);0357     0358     0359   <span class="keyword">case</span> 2, <span class="comment">% sagittal unflipped</span>0360     0361     <span class="comment">% orient = 2:  The primary orientation of the data on disk is in the sagittal</span>0362     <span class="comment">% plane relative to the object scanned.  Most commonly, the fastest moving</span>0363     <span class="comment">% index through the voxels that are part of this sagittal image would span the</span>0364     <span class="comment">% posterior-&gt;anterior extent of the structure imaged, with the next fastest</span>0365     <span class="comment">% moving index spanning the inferior-&gt;superior extent of the structure.  This</span>0366     <span class="comment">% 'orient' flag would indicate to Analyze that this data should be placed in</span>0367     <span class="comment">% the Y-Z plane of the 3D Analyze Coordinate System, with the X dimension</span>0368     <span class="comment">% being the slice direction.</span>0369     0370     <span class="comment">% For the 'sagittal unflipped' type, the voxels are stored with</span>0371     <span class="comment">% Pixels in 'y' axis (varies fastest) - from patient posterior to anterior</span>0372     <span class="comment">% Rows in   'z' axis                  - from patient inferior to superior</span>0373     <span class="comment">% Slices in 'x' axis                  - from patient right to left</span>0374     0375     fprintf(<span class="string">'...reading sagittal unflipped orientation\n'</span>);0376     0377     avw.img = zeros(SliceDim,PixelDim,RowDim);0378     0379     n = 1;0380     y = 1:PixelDim;         <span class="comment">% posterior to anterior (fastest)</span>0381     0382     <span class="keyword">for</span> x = 1:SliceDim,     <span class="comment">% right to left (slowest)</span>0383       <span class="keyword">for</span> z = 1:RowDim,   <span class="comment">% inferior to superior</span>0384         0385         <span class="comment">% load Z row of Y values into X slice avw.img</span>0386         avw.img(x,y,z) = tmp(n:n+(PixelDim-1));0387         n = n + PixelDim;0388       <span class="keyword">end</span>0389     <span class="keyword">end</span>0390     0391     <span class="comment">% rearrange avw.hdr.dime.dim or avw.hdr.dime.pixdim</span>0392     avw.hdr.dime.dim(2:4) = int16([SliceDim,PixelDim,RowDim]);0393     avw.hdr.dime.pixdim(2:4) = single([SliceSz,PixelSz,RowSz]);0394     0395     0396     <span class="comment">%--------------------------------------------------------------------------------</span>0397     <span class="comment">% Orient values 3-5 have the second index reversed in order, essentially</span>0398     <span class="comment">% 'flipping' the images relative to what would most likely become the vertical</span>0399     <span class="comment">% axis of the displayed image.</span>0400     <span class="comment">%--------------------------------------------------------------------------------</span>0401     0402   <span class="keyword">case</span> 3, <span class="comment">% transverse/axial flipped</span>0403     0404     <span class="comment">% orient = 3:  The primary orientation of the data on disk is in the</span>0405     <span class="comment">% transverse plane relative to the object scanned.  Most commonly, the fastest</span>0406     <span class="comment">% moving index through the voxels that are part of this transverse image would</span>0407     <span class="comment">% span the right-&gt;left extent of the structure imaged, with the next fastest</span>0408     <span class="comment">% moving index spanning the *anterior-&gt;posterior* extent of the structure.  This</span>0409     <span class="comment">% 'orient' flag would indicate to Analyze that this data should be placed in</span>0410     <span class="comment">% the X-Y plane of the 3D Analyze Coordinate System, with the Z dimension</span>0411     <span class="comment">% being the slice direction.</span>0412     0413     <span class="comment">% For the 'transverse flipped' type, the voxels are stored with</span>0414     <span class="comment">% Pixels in 'x' axis (varies fastest) - from patient right to Left</span>0415     <span class="comment">% Rows in   'y' axis                  - from patient anterior to Posterior *</span>0416     <span class="comment">% Slices in 'z' axis                  - from patient inferior to Superior</span>0417     0418     fprintf(<span class="string">'...reading axial flipped (+Y from Anterior to Posterior)\n'</span>);0419     0420     avw.img = zeros(PixelDim,RowDim,SliceDim);0421     0422     n = 1;0423     x = 1:PixelDim;0424     <span class="keyword">for</span> z = 1:SliceDim,0425       <span class="keyword">for</span> y = RowDim:-1:1, <span class="comment">% flip in Y, read A2P file into P2A 3D matrix</span>0426         0427         <span class="comment">% load a flipped Y row of X values into Z slice avw.img</span>0428         avw.img(x,y,z) = tmp(n:n+(PixelDim-1));0429         n = n + PixelDim;0430       <span class="keyword">end</span>0431     <span class="keyword">end</span>0432     0433     <span class="comment">% no need to rearrange avw.hdr.dime.dim or avw.hdr.dime.pixdim</span>0434     0435     0436   <span class="keyword">case</span> 4, <span class="comment">% coronal flipped</span>0437     0438     <span class="comment">% orient = 4:  The primary orientation of the data on disk is in the coronal</span>0439     <span class="comment">% plane relative to the object scanned.  Most commonly, the fastest moving</span>0440     <span class="comment">% index through the voxels that are part of this coronal image would span the</span>0441     <span class="comment">% right-&gt;left extent of the structure imaged, with the next fastest moving</span>0442     <span class="comment">% index spanning the *superior-&gt;inferior* extent of the structure.  This 'orient'</span>0443     <span class="comment">% flag would indicate to Analyze that this data should be placed in the X-Z</span>0444     <span class="comment">% plane of the 3D Analyze Coordinate System, with the Y dimension being the</span>0445     <span class="comment">% slice direction.</span>0446     0447     <span class="comment">% For the 'coronal flipped' type, the voxels are stored with</span>0448     <span class="comment">% Pixels in 'x' axis (varies fastest) - from patient right to Left</span>0449     <span class="comment">% Rows in   'z' axis                  - from patient superior to Inferior*</span>0450     <span class="comment">% Slices in 'y' axis                  - from patient posterior to Anterior</span>0451     0452     fprintf(<span class="string">'...reading coronal flipped (+Z from Superior to Inferior)\n'</span>);0453     0454     avw.img = zeros(PixelDim,SliceDim,RowDim);0455     0456     n = 1;0457     x = 1:PixelDim;0458     <span class="keyword">for</span> y = 1:SliceDim,0459       <span class="keyword">for</span> z = RowDim:-1:1, <span class="comment">% flip in Z, read S2I file into I2S 3D matrix</span>0460         0461         <span class="comment">% load a flipped Z row of X values into Y slice avw.img</span>0462         avw.img(x,y,z) = tmp(n:n+(PixelDim-1));0463         n = n + PixelDim;0464       <span class="keyword">end</span>0465     <span class="keyword">end</span>0466     0467     <span class="comment">% rearrange avw.hdr.dime.dim or avw.hdr.dime.pixdim</span>0468     avw.hdr.dime.dim(2:4) = int16([PixelDim,SliceDim,RowDim]);0469     avw.hdr.dime.pixdim(2:4) = single([PixelSz,SliceSz,RowSz]);0470     0471     0472   <span class="keyword">case</span> 5, <span class="comment">% sagittal flipped</span>0473     0474     <span class="comment">% orient = 5:  The primary orientation of the data on disk is in the sagittal</span>0475     <span class="comment">% plane relative to the object scanned.  Most commonly, the fastest moving</span>0476     <span class="comment">% index through the voxels that are part of this sagittal image would span the</span>0477     <span class="comment">% posterior-&gt;anterior extent of the structure imaged, with the next fastest</span>0478     <span class="comment">% moving index spanning the *superior-&gt;inferior* extent of the structure.  This</span>0479     <span class="comment">% 'orient' flag would indicate to Analyze that this data should be placed in</span>0480     <span class="comment">% the Y-Z plane of the 3D Analyze Coordinate System, with the X dimension</span>0481     <span class="comment">% being the slice direction.</span>0482     0483     <span class="comment">% For the 'sagittal flipped' type, the voxels are stored with</span>0484     <span class="comment">% Pixels in 'y' axis (varies fastest) - from patient posterior to Anterior</span>0485     <span class="comment">% Rows in   'z' axis                  - from patient superior to Inferior*</span>0486     <span class="comment">% Slices in 'x' axis                  - from patient right to Left</span>0487     0488     fprintf(<span class="string">'...reading sagittal flipped (+Z from Superior to Inferior)\n'</span>);0489     0490     avw.img = zeros(SliceDim,PixelDim,RowDim);0491     0492     n = 1;0493     y = 1:PixelDim;0494     0495     <span class="keyword">for</span> x = 1:SliceDim,0496       <span class="keyword">for</span> z = RowDim:-1:1, <span class="comment">% flip in Z, read S2I file into I2S 3D matrix</span>0497         0498         <span class="comment">% load a flipped Z row of Y values into X slice avw.img</span>0499         avw.img(x,y,z) = tmp(n:n+(PixelDim-1));0500         n = n + PixelDim;0501       <span class="keyword">end</span>0502     <span class="keyword">end</span>0503     0504     <span class="comment">% rearrange avw.hdr.dime.dim or avw.hdr.dime.pixdim</span>0505     avw.hdr.dime.dim(2:4) = int16([SliceDim,PixelDim,RowDim]);0506     avw.hdr.dime.pixdim(2:4) = single([SliceSz,PixelSz,RowSz]);0507     0508   <span class="keyword">otherwise</span>0509     0510     error(<span class="string">'unknown value in avw.hdr.hist.orient, try explicit IMGorient option.'</span>);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -