Created
March 29, 2011 17:08
-
-
Save johncolby/892775 to your computer and use it in GitHub Desktop.
Patches revision 72c87f6 of along-tract-stats to use normal structures instead of datasets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/trk_compile_data.m b/trk_compile_data.m | |
index 0b2ddfe..90d3d15 100644 | |
--- a/trk_compile_data.m | |
+++ b/trk_compile_data.m | |
@@ -52,17 +52,12 @@ function [track_means,starting_pts_out] = trk_compile_data(subsDir,subIDs,tract_ | |
if nargin < 7 || isempty(saveASCII), saveASCII = 0; end | |
if nargin < 6 || isempty(saveTrk), saveTrk = 0; end | |
if nargin < 5 || isempty(starting_pts_in) | |
- starting_pts_in = dataset(); | |
-elseif ~iscell(starting_pts_in.Subject) % Reformat to cells if subIDs are all numeric | |
- starting_pts_in.Subject = cellfun(@num2str, num2cell(starting_pts_in.Subject), 'UniformOutput', 0); | |
+ starting_pts_in = struct(); | |
end | |
if nargin < 4 || isempty(outDir), outDir = pwd; end | |
if nargin < 3, error('Need more input arguments'), end | |
if isnumeric(subIDs), subIDs = num2cell(subIDs); end | |
-tract_info.startPt = cell2mat(cellfun(@eval, tract_info.startPt, 'UniformOutput',false)); | |
-tract_info.view = cell2mat(cellfun(@eval, tract_info.view, 'UniformOutput',false)); | |
- | |
%% Setup output files and variables | |
% Save one file for overall track properties | |
fid1 = fopen(fullfile(outDir, 'trk_props_long.txt'), 'wt'); | |
@@ -77,7 +72,7 @@ for iFig=1:length(tract_info), fh(iFig) = figure; hold on; end | |
% Initialize variables | |
track_means = struct([]); | |
-starting_pts_out = dataset(); | |
+starting_pts_out = struct([]); | |
%% Main loop to extract along-tract properties | |
% Loop over tracks | |
@@ -117,9 +112,9 @@ for iTrk=1:length(tract_info) | |
% Determine 'pt_start' near tract origin. First look in | |
% 'starting_pts_in' if available, and then the 'tract_info' defaults | |
if ~isempty(starting_pts_in) | |
- pt_start = double(starting_pts_in(strcmp(subStr, starting_pts_in.Subject) &... | |
- strcmp(tract_info.Tract(iTrk), starting_pts_in.Tract) &... | |
- strcmp(tract_info.Hemisphere(iTrk), starting_pts_in.Hemisphere),4:6)); | |
+ pt_start = starting_pts_in(strcmp(subStr, {starting_pts_in.Subject}) &... | |
+ strcmp(tract_info.Tract(iTrk), {starting_pts_in.Tract}) &... | |
+ strcmp(tract_info.Hemisphere(iTrk), {starting_pts_in.Hemisphere})).pt_start; | |
end | |
if isempty(pt_start) | |
pt_start = tract_info.startPt(iTrk,:); | |
@@ -128,8 +123,11 @@ for iTrk=1:length(tract_info) | |
% Reorient streamlines according to 'pt_start'. Determine | |
% interactively if needed | |
[tracks_interp pt_start] = trk_flip(header, tracks_interp, pt_start, volume); | |
- starting_pts_out = [starting_pts_out; dataset({subStr}, tract_info.Hemisphere(iTrk), tract_info.Tract(iTrk), pt_start(1), pt_start(2), pt_start(3),... | |
- 'VarNames',{'Subject','Hemisphere','Tract','PointX','PointY','PointZ'})]; | |
+ starting_pts_out = [starting_pts_out; | |
+ struct('Subject', {subStr},... | |
+ 'Hemisphere', tract_info.Hemisphere(iTrk),... | |
+ 'Tract', tract_info.Tract(iTrk),... | |
+ 'pt_start', pt_start)]; | |
tracks_interp_str = trk_restruc(tracks_interp); | |
% Extract scalar values from 'volume' | |
@@ -189,7 +187,7 @@ for iTrk=1:length(tract_info) | |
end | |
%% Clean up | |
-export(starting_pts_out, 'file', fullfile(outDir, 'starting_pts_out.txt')) | |
+save starting_pts_out.mat starting_pts_out | |
close all | |
fclose all; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment