forked from Chaogan-Yan/REST
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rest_Powerspectrum_start.m
executable file
·65 lines (55 loc) · 3.43 KB
/
rest_Powerspectrum_start.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function rest_Powerspectrum_start()
% Prepare for showing the Power Spectrum and the Time course of user specified voxel whose coordinates could be set with SliceViewer
% By YAN Chao-Gan and Dong Zhang-Ye 101025.
% State Key Laboratory of Cognitive Neuroscience and Learning, Beijing Normal University, China, 100875
% http://www.restfmri.net
% Mail to Authors: <a href="[email protected]">YAN Chao-Gan</a>; <a href="[email protected]">DONG Zhang-Ye</a>
% Version=1.0;
% Release=20101025;
try
[filename, pathname] = uigetfile({'*.img;*.nii;*.nii.gz','Brain Image Files (*.img;*.nii;*.nii.gz)';'*.*', 'All Files (*.*)';}, ...
'Pick one functional EPI brain map in the dataset''s directory');
if any(filename~=0) && ischar(filename), % not canceled and legal
if ~strcmpi(pathname(end), filesep)%revise pathname to remove extension
pathname = [pathname filesep];
end
theBrainMap =[pathname filename];
theViewer =rest_sliceviewer('ShowImage', theBrainMap);
%Set the ALFF figure to show corresponding voxel's time-course and its freq amplitude
theDataSetDir =pathname;
theVoxelPosition=rest_sliceviewer('GetPosition', theViewer);
theSamplePeriod =inputdlg('Please input the Sample Period: (i.e. TR)', ...
'REST Power Spectrum');
theSamplePeriod =str2num(theSamplePeriod{1});
theBandRange =inputdlg('Please input the Band Limit you want to see', ...
'REST Power Spectrum',1,{'[0.01 0.08]'});
theBandRange =eval(['[',theBandRange{1},']']);
button = questdlg('Do you want to yoke with structural image (e.g., ch2.nii)?','Yoke with structural image','Yes','No','Yes');
if strcmpi(button,'Yes')
[filenameU, pathnameU] = uigetfile({'*.img;*.nii;*.nii.gz','Brain Image Files (*.img;*.nii;*.nii.gz)';'*.*', 'All Files (*.*)';}, ...
'Pick one Structure brain map for Underlay (e.g., ch2.nii)');
theNewUnderlay =[pathnameU,filesep,filenameU];
theViewer2 =rest_sliceviewer('ShowImage', theNewUnderlay);
end
rest_powerspectrum('ShowFluctuation', theDataSetDir, theVoxelPosition, ...
theSamplePeriod, theBandRange);
%Update the Callback
theCallback ='';
cmdDataSetDir =sprintf('theDataSetDir= ''%s'';', theDataSetDir);
cmdBrainMap =sprintf('theVoxelPosition=rest_sliceviewer(''GetPosition'', %g);', theViewer);
cmdSamplePeriod =sprintf('theSamplePeriod= %g;', theSamplePeriod);
cmdBandRange =sprintf('theBandRange= [%g, %g];', theBandRange(1), theBandRange(2));
cmdUpdateWaveGraph ='rest_powerspectrum(''ShowFluctuation'', theDataSetDir, theVoxelPosition, theSamplePeriod, theBandRange);';
theCallback =sprintf('%s\n%s\n%s\n%s\n%s\n',cmdDataSetDir, ...
cmdBrainMap, cmdSamplePeriod, cmdBandRange, ...
cmdUpdateWaveGraph);
cmdClearVar ='clear theDataSetDir theVoxelPosition theSamplePeriod theBandRange;';
rest_sliceviewer('UpdateCallback', theViewer, [theCallback cmdClearVar], 'ALFF Analysis');
% Update some Message
theMsg =sprintf('TR( s): %g\nBand( Hz): %g~%g', ...
theSamplePeriod, theBandRange(1), theBandRange(2) );
rest_sliceviewer('SetMessage', theViewer, theMsg);
end
catch
rest_misc( 'DisplayLastException');
end