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 CenterFile Exchange에서 Display Image에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by