Skip to content

Commit

Permalink
Update PyD to DKE conversion scripts (#210)
Browse files Browse the repository at this point in the history
* Convert AWF array to float

* Update input file check in dwipy

* Fixed dockerfile bugs (#202)

* Update files to delete

* Update Changelog

* Update PyDesigner version info

* Update des2dke B0 name

* WMTI Calculation Fix (#204)

* Add intra- and extra-axonal diffusivities to WMTI

* Convert `json2fslgrad` from method to func

* Update CHANGELOG

* Update v0.31>>v0.32

* Update doc table of file outputs

* Update README image size

* Change WMTI file names

* Change filenames again

* Minor WMTI bugfixes

* Transpose B0 BVALS in json2fslgrad (#206)

* Update changelog (#207)

* Update PyD to DKE conversion script (#209)

* Rename Extras to extras

* Init FT parameter file

* Allow FWHM res change in DKE param file

* Update PyD to DKE conversion script

* Update changelog
  • Loading branch information
TheJaeger authored Apr 21, 2020
1 parent 63aa762 commit db39ed4
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 5 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ page
`v0.32`_
--------

Apr 10, 2020
Apr 21, 2020

**Added**:

Expand All @@ -21,6 +21,9 @@ Apr 10, 2020
* ``json2fslgrad`` now transposes B0s in BVAL file in accordance with
FSL's gradient scheme
* Documentation update
* ``Extras`` directory renamed to ``extras``
* DKE conversion scripts modified to correctly create ft and dke
parameter files

**Removed**:

Expand Down
21 changes: 20 additions & 1 deletion Extras/des2dke.m → extras/des2dke.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function des2dke(inDir)
save(fullfile(p,'gradient_dke.txt'),'Gradient1','-ASCII');

%% Create DKE Parameter File
fprintf('4: Creating parameter files\n');
fprintf('4: Creating DKE parameter files\n');
fid=fopen('dke_parameters.txt'); %Original file
fout=fullfile(dke_Path,'dke_parameters.txt');% new file

Expand All @@ -96,9 +96,28 @@ function des2dke(inDir)
s=fgetl(fid);
s=strrep(s,'dir-sub-changeme',dke_Path); %s=strrep(s,'A201', subject_list{i}) replace subject
s=strrep(s,'ndir = changeme',sprintf('ndir = %d',length(b1_idx_new)));
s=strrep(s,'bval = changeme',sprintf('bval = [%s]', num2str(unique(bval))));
s=strrep(s,'fn-gradients-changeme',fullfile(dke_Path,'gradient_dke.txt'));
s=strrep(s,'fwhm_img = res-changeme',sprintf('fwhm_img = 0 * [%s]', num2str(hdr.PixelDimensions(1:3),3)));
fprintf(fidout,'%s\n',s);
end
fclose(fid);
fclose(fidout);
fprintf('.....Completed.....\n');

%% Create FT Parameter File
fprintf('4: Creating FT parameter files\n');
fid=fopen('ft_parameters.txt'); %Original file
fout=fullfile(dke_Path,'ft_parameters.txt');% new file

fidout=fopen(fout,'w');

while(~feof(fid))
s=fgetl(fid);
s=strrep(s,'dir-sub-changeme',dke_Path); %s=strrep(s,'A201', subject_list{i}) replace subject
fprintf(fidout,'%s\n',s);
end
fclose(fid);
fclose(fidout);
fprintf('.....Completed.....\n');

6 changes: 3 additions & 3 deletions Extras/dke_parameters.txt → extras/dke_parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ preprocess_options.fn_nii = 'dke.nii'; % four-dimensional nifti image fi

% imaging diffusion weightings and directions

bval = [0 1000 2000]; % diffusion weightings (b-values) in s/mm^2 units; the first element of vector must always be 0
bval = bval-changeme; % diffusion weightings (b-values) in s/mm^2 units; the first element of vector must always be 0

ndir = changeme; % number of gradient directions; if a scalar value is specified, the number of gradient directions for all b values is set to the scalar; otherwise, a 1-by-(nbval-1) vector should be specified, with each element of the vector corresponding to the number of gradient directions for a nonzero b-value

Expand Down Expand Up @@ -63,7 +63,7 @@ dti_method.noise_tolerance = 0.09; % threshold for outlier detection

% diffusion-weighted image filtering

fwhm_img = 0 * [2.0 2.0 2.0]; % full width at half maximum (FWHM) (in mm) of Gaussian kernel for smoothing diffusion-weighted images (default: 1.25 * voxel size); a zero value indicates no smoothing
fwhm_img = res-changeme; % full width at half maximum (FWHM) (in mm) of Gaussian kernel for smoothing diffusion-weighted images (default: 1.25 * voxel size); a zero value indicates no smoothing

% Rician noise subtraction

Expand All @@ -72,7 +72,7 @@ fwhm_noise = 0; % FWHM (in mm) of Gaussian kernel

% parametric map filtering

median_filter_method = 0; % selective median filtering applied to voxels that violate the minimum directional kurtosis constraints (default: 2): (0) no filtering; (1) weak filtering (voxels with less than 15 unviolated constraints will be filtered); (2) strong filtering (voxels with any constraint violation will be filtered)
median_filter_method = 1; % selective median filtering applied to voxels that violate the minimum directional kurtosis constraints (default: 2): (0) no filtering; (1) weak filtering (voxels with less than 15 unviolated constraints will be filtered); (2) strong filtering (voxels with any constraint violation will be filtered)

% parametric map interpolation

Expand Down
40 changes: 40 additions & 0 deletions extras/ft_parameters.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
%--------------------------------------------------------------------------
%USER OPTIONS
%--------------------------------------------------------------------------
studydir = 'dir-sub-changeme'; %Full path to directory containing DT.mat, KT.mat, and fa.nii files.
subject_list = {''}; %Specify subject numbers (i.e. {'Subject01','Subject02','Subject03',...}).

%ODF Optimizatinon

odf_optimization = 1; %Analyze the kurtosis dODF (1) or skip odf optimization (0). This step must be performed prior to tractography.
sd = 4; %[3,4, or 5] Sampling distribution to use. See sphericalgrid3(4,5).m documentation for more info.
quasiNewton = 1; %Apply non-linear optimization to increase accuracy of peak detection (1) or use orientations directly from the pre-defined sampling distribution (0).
radial_weight = 4; %Radial weighting power.Recommended radial_weight = 4.
release_memory = 0; %Do not release memory (0), release memory after each subject (1), or release memory more frequently (2). See User's Guide for additional info.
wrt_flg = 1; %Write outputs (1) or don't write outputs (0).
pre_name = ''; %String to append to the beginning of output names.
post_name = ''; %String to append to the end of output names.

%Tractography

tractography_flg = 1; %Perform tractography (1) or don't perform tractography (0).
fa_threshold = 0.1; %FA threshold.
angle_threshold = 35; %Angle threshold in degrees.
trk_length = 20; %Minimum tract length in mm.
step_size = 1; %Step size in mm (0 defaults to half of the voxel length).
trk_mask = ''; %Path to tracking mask to apply in addition to other tract termination criteria defined above. Should be in the same orientation as the fa.nii image.
seed_mask = ''; %Mask within which to put seeds. Should be in the same orientation as the fa.nii image
seednum = 1E5; %Number of random seed points in the tracking mask.
shift = 0.5; %Shift applied to voxel coordinates in .trk file.
output_DTI_trks = 1; %Include tractography performed from just the diffusion tensor (1) or don't (0).
image_orientation = 'LAS'; %Orientation of input image volumes. By convention, spm writes images in 'LAS.'
odf_orientation = 'RAS'; %Orientation of the gradient table used to estimate the diffusion and kurtosis tensors. If SPM is used to estimate the gradient tables, this should be 'LAS.'


%Make DSI Studio .fib file

make_fib_file = 1; %Make .fib file to read in DSI Studio (1) or skip this step (0).
save_odfs = 1; %Save dODFS in .fib file (1) or not (0). This only affects visualization as orientations are still saved for tractography.
scale_odf = 0.5; %Affects overall size of odfs in .fib file. This only affects visualization.
odf_size = 20000; %Size of odf_n variables. Reduce this if there are issues with RAM.
odf_res = 'low'; %{'low' or 'high'}; Number of points saved in ODFs ~ only affects visualization. Use 'low' to reduce memory requirements and use 'high' for the smoothest dODF surface renderings.

0 comments on commit db39ed4

Please sign in to comment.