在MATLAB中解压MRI文件

huangapple go评论91阅读模式
英文:

Un-gzipping MRI Files in MATLAB

问题

I'm learning MATLAB +SPM12 to do structural MRI analysis. To do this, I need to change the format of the files from gz to NIFTI. The guide I'm using said to use:

gunzip('*.gz')
Flanker=gunzip('*.gz')
Dot indexing is not supported for variables of this type.

Error in gunzip (line 71)
       destinationIsSameAsSource = ismember(fullfile({entries.file}), fullfile(rootDir,outputDir,files));

I tried many different fixes from a google search:

gunzip('sub-08.gz')
gunzip('sub-08.gz')
>> gunzip('sub-08', '*.gz')
unzip('sub-08_T1w.nii.gz','Sub-08')

None of these worked for various reasons. "sub-08" is the name of the folder trying to unzip.

英文:

I'm learning MATLAB +SPM12 to do structural MRI analysis. To do this, I need to change the format of the files from gz to NIFTI. The guide I'm using said to use

gunzip('*.gz')
Flanker=gunzip('*.gz')
Dot indexing is not supported for variables of this type.

Error in gunzip (line 71)
       destinationIsSameAsSource = ismember(fullfile({entries.file}), fullfile(rootDir,outputDir,files));

I tried many different fixes from a google search

gunzip('sub-08.gz')
gunzip('sub-08.gz')
>> gunzip('sub-08', '*.gz')
 unzip('sub-08_T1w.nii.gz','Sub-08')`

None of these worked for various reasons
sub-08 is the name of the folder trying to unzip.

答案1

得分: 1

如果 sub-08 是一个包含gzip文件的文件夹,那么使用 res = gunzip('sub-08') 来提取所有这些文件,包括子文件夹中的文件。res 将是未压缩文件的文件名列表。

英文:

If sub-08 is a folder that contains gzip files, then use res = gunzip('sub-08') to extract all of them, including those in sub-sub-folders. res will be a list of the filenames of the uncompressed files.

答案2

得分: 0

当我在一个没有任何 .gz 文件的目录中运行 gunzip('*.gz') 时,我会得到与您报告的相同错误信息("不支持对此类型变量进行点索引")。这似乎是MATLAB中的一个错误,它应该提供更具信息性的错误消息。

如果您在包含 .gz 文件的目录中运行该命令,它将按照文档的描述正常工作。您也可以提供文件的路径,例如:

gunzip('sub-08/*.gz')

或者,正如Mark Adler在他的回答中所说,您也可以只提供目录的名称,MATLAB会自动查找其中的 .gz 文件。尽管这并未在文档中明确说明(如果有的话,说明可能不够清晰)。

gunzip('sub-08')

请注意,在这些示例中,sub-08 是当前目录下的一个子目录,其中包含带有 .gz 扩展名的文件。

您可以使用 pwdcd 命令来确定当前目录是什么,以及使用 cd('路径') 来更改当前目录。

如果不确定,您可以使用完整路径来使用 gunzip 命令:

gunzip('/home/kylee/mri/sub-08/*.gz') % (或者您实际的路径)
英文:

When I give gunzip('*.gz') in a directory without any .gz files, I get the same error you are reporting ("Dot indexing is not supported for variables of this type"). This looks to be a bug in MATLAB, it should give a more informative error message.

If you give that command in a directory that does have .gz files, it works as documented. You can also give the path to the files, for example

gunzip('sub-08/*.gz')

Or, as Mark Adler said in his answer, you can just give the name of the directory, MATLAB will find the .gz files in it automatically. This is not documented though (or if it is, it's not clear enough).

gunzip('sub-08')

Note that in these examples sub-08 is a directory under the current directory and contains files with a .gz extension.

You can type pwd or cd to figure out what the current directory is, and cd('path') to change the current directory.

If unsure, you can use the gunzip command with full path:

gunzip('\home\kylee\mri\sub-08\*.gz') % (or whatever path you have of course)

huangapple
  • 本文由 发表于 2023年6月29日 02:20:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/76575771.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定