0001 function fe = feConnectomeInit(dwiFile,fgFileName,feFileName,savedir,dwiFileRepeated,anatomyFile,varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 feOpenLocalCluster
0014
0015
0016 fe = feCreate;
0017
0018
0019 if notDefined('savedir'), savedir = fullfile(fileparts(fgFileName),'life');
0020 end
0021 fe = feSet(fe,'savedir',savedir);
0022
0023
0024 tempNi = niftiRead(dwiFile);
0025 fe = feSet(fe, 'img2acpc xform', tempNi.qto_xyz);
0026 fe = feSet(fe, 'acpc2img xform', inv(tempNi.qto_xyz));
0027 clear tempNi
0028
0029
0030 if isstruct(fgFileName), n = fgFileName.name;
0031 else [~,n] = fileparts(fgFileName);
0032 end
0033
0034 if notDefined('feFileName'),
0035 feFileName = sprintf('%s-%s', datestr(now,30),n);
0036 end
0037 fe = feSet(fe, 'name',feFileName);
0038
0039
0040 if isstruct(fgFileName), fg = fgFileName; clear fgFileName
0041 else
0042 fprintf('\n[%s]\n loading fiber from file: %s\n',mfilename,fgFileName)
0043 fg = fgRead(fgFileName);
0044 end
0045
0046
0047
0048
0049 fe = feSet(fe,'fg from acpc',fg);
0050
0051
0052
0053 fe = feSet(fe,'roi fg',[]);
0054 clear fg
0055
0056
0057 tic
0058 if ~isempty(varargin)
0059 axialDiffusion = varargin{1}(1);
0060 radialDiffusion = varargin{1}(2);
0061 else
0062 axialDiffusion = 1;
0063 radialDiffusion = 0;
0064 end
0065 dParms(1) = axialDiffusion;
0066 dParms(2) = radialDiffusion;
0067 dParms(3) = radialDiffusion;
0068
0069 fe = feSet(fe,'model tensor',dParms);
0070
0071 fprintf('\n[%s] Computing fibers'' tensors... ',mfilename);
0072 fe = feSet(fe, 'tensors', feComputeCanonicalDiffusion(fe.fg.fibers, dParms));
0073 toc
0074
0075
0076 roi = feGet(fe,'roi coords');
0077 fe = feSet(fe,'voxel 2 fiber node pairs',fefgGet(feGet(fe,'fg img'),'v2fn',roi));
0078 fe = feGetConnectomeInfo(fe);
0079
0080
0081 fe = feConnectomeSetDwi(fe,dwiFile,0);
0082
0083
0084
0085 if ~notDefined('dwiFileRepeated')
0086 fe = feConnectomeSetDwi(fe,dwiFileRepeated,1);
0087 end
0088
0089
0090 if ~notDefined('anatomyFile')
0091 fe = feSet(fe,'anatomy file',anatomyFile);
0092 end
0093
0094
0095 fe = feConnectomeBuildModel(fe);
0096
0097 return