Reformating cell array of chars

1 回表示 (過去 30 日間)
MiauMiau
MiauMiau 2017 年 3 月 25 日
編集済み: Jan 2017 年 3 月 25 日
Hi
What I want is the following: I have 4D-files, I want to extract the names of the 3d slices in these files. Say I have a 4D file, which consists of three such slices, I would like to have the names of these slices as follows:
a = {
'/myComputer/10_22022017_0833036_2_1_wipepi168V4.nii,1'
'/myComputer/10_22022017_0833036_2_1_wipepi168V4.nii,2'
'/myComputer/10_22022017_0833036_2_1_wipepi168V4.nii,3'}
This gives me here a 3x1 cell. If there are many such slices, doing this manually is of course quite difficult. There is a function which recursively finds the name of the slices of 4D volumes in a folder, however it gives back a char array, e.g.:
/myComputer/10_22022017_0833036_2_1_wipepi168V4.nii,1
/myComputer/10_22022017_0833036_2_1_wipepi168V4.nii,2
/myComputer/10_22022017_0833036_2_1_wipepi168V4.nii,3
My question: How can I convert this char array in the format above, e.g. into a 3x1 cell containing the names? It should be as automated as possible (sometimes there might be 200 slices, sometimes 300 etc.)
Thanks

回答 (1 件)

Jan
Jan 2017 年 3 月 25 日
編集済み: Jan 2017 年 3 月 25 日
If the function replies a char array, simply use:
a = cellstr(c)
I guess, that it is easy to write a function, which finds the file names:
DirList = dir('/myComputer/*.nii,*');
FileList = fullfile('/myComputer/', {DirList.name});

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by