Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fdt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FSL
fdt
Commits
c38b202c
Commit
c38b202c
authored
12 years ago
by
Moises Fernandez
Browse files
Options
Downloads
Patches
Plain Diff
Changes in grad-nonlin functions
parent
38ab83a8
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CUDA/xfibres_gpu.cu
+5
-20
5 additions, 20 deletions
CUDA/xfibres_gpu.cu
CUDA/xfibres_gpu.cuh
+0
-2
0 additions, 2 deletions
CUDA/xfibres_gpu.cuh
CUDA/xfibres_gpu.h
+0
-2
0 additions, 2 deletions
CUDA/xfibres_gpu.h
xfibres_gpu.cc
+2
-24
2 additions, 24 deletions
xfibres_gpu.cc
with
7 additions
and
48 deletions
CUDA/xfibres_gpu.cu
+
5
−
20
View file @
c38b202c
...
...
@@ -31,8 +31,6 @@ void xfibres_gpu( //INPUT
const
Matrix
bvecs
,
const
Matrix
bvals
,
const
Matrix
gradm
,
const
Matrix
Qform
,
const
Matrix
Qform_inv
,
const
NEWIMAGE
::
volume
<
int
>
vol2matrixkey
,
const
NEWMAT
::
Matrix
matrix2volkey
,
const
NEWIMAGE
::
volume
<
float
>
mask
,
...
...
@@ -64,7 +62,7 @@ void xfibres_gpu( //INPUT
vector
<
Matrix
>
bvecs_vec
,
bvals_vec
;
///// FIT /////
prepare_data_gpu_FIT
(
datam
,
bvecs
,
bvals
,
gradm
,
Qform
,
Qform_inv
,
datam_vec
,
bvecs_vec
,
bvals_vec
,
datam_host
,
bvecs_host
,
bvals_host
,
alpha_host
,
beta_host
,
params_host
,
tau_host
);
prepare_data_gpu_FIT
(
datam
,
bvecs
,
bvals
,
gradm
,
datam_vec
,
bvecs_vec
,
bvals_vec
,
datam_host
,
bvecs_host
,
bvals_host
,
alpha_host
,
beta_host
,
params_host
,
tau_host
);
thrust
::
device_vector
<
double
>
datam_gpu
=
datam_host
;
thrust
::
device_vector
<
double
>
bvecs_gpu
=
bvecs_host
;
...
...
@@ -125,7 +123,7 @@ void xfibres_gpu( //INPUT
// Correct bvals/bvecs accounting for Gradient Nonlinearities
// ColumnVector grad_nonlin has 9 entries, corresponding to the 3 components of each of the x,y and z gradient deviation
void
correct_bvals_bvecs
(
const
Matrix
&
bvals
,
const
Matrix
&
bvecs
,
const
ColumnVector
&
grad_nonlin
,
const
Matrix
&
Qform
,
const
Matrix
&
Qform_inv
,
Matrix
&
bvals_c
,
Matrix
&
bvecs_c
){
void
correct_bvals_bvecs
(
const
Matrix
&
bvals
,
const
Matrix
&
bvecs
,
const
ColumnVector
&
grad_nonlin
,
Matrix
&
bvals_c
,
Matrix
&
bvecs_c
){
bvals_c
=
bvals
;
bvecs_c
=
bvecs
;
Matrix
L
(
3
,
3
);
//gradient coil tensor
float
mag
;
...
...
@@ -137,22 +135,11 @@ void correct_bvals_bvecs(const Matrix& bvals,const Matrix& bvecs, const ColumnVe
for
(
int
l
=
1
;
l
<=
bvals
.
Ncols
();
l
++
){
if
(
bvals
(
1
,
l
)
>
0
){
//do not correct b0s
//Rotate bvecs to scanner's coordinate system
ColumnVector
bvec_tmp
(
3
);
bvec_tmp
=
Qform
*
bvecs
.
Column
(
l
);
bvec_tmp
(
1
)
=-
bvec_tmp
(
1
);
//Sign-flip X coordinate
//Correct for grad-nonlin in scanner's coordinate system
bvecs_c
.
Column
(
l
)
=
(
Id
+
L
)
*
bvec_tmp
;
//bvecs.Column(l);
bvecs_c
.
Column
(
l
)
=
(
Id
+
L
)
*
bvecs
.
Column
(
l
);
mag
=
sqrt
(
bvecs_c
(
1
,
l
)
*
bvecs_c
(
1
,
l
)
+
bvecs_c
(
2
,
l
)
*
bvecs_c
(
2
,
l
)
+
bvecs_c
(
3
,
l
)
*
bvecs_c
(
3
,
l
));
if
(
mag
!=
0
)
bvecs_c
.
Column
(
l
)
=
bvecs_c
.
Column
(
l
)
/
mag
;
bvals_c
(
1
,
l
)
=
mag
*
mag
*
bvals
(
1
,
l
);
bvec_tmp
=
bvecs_c
.
Column
(
l
);
//Rotate corrected bvecs back to voxel coordinate system
bvec_tmp
(
1
)
=-
bvec_tmp
(
1
);
//Sign-flip X coordinate
bvecs_c
.
Column
(
l
)
=
Qform_inv
*
bvec_tmp
;
bvals_c
(
1
,
l
)
=
mag
*
mag
*
bvals
(
1
,
l
);
//mag^2 as b propto |G|^2
}
}
}
...
...
@@ -335,8 +322,6 @@ void prepare_data_gpu_FIT( //INPUT
const
Matrix
bvecs
,
const
Matrix
bvals
,
const
Matrix
gradm
,
const
Matrix
Qform
,
const
Matrix
Qform_inv
,
//OUTPUT
vector
<
ColumnVector
>&
datam_vec
,
vector
<
Matrix
>&
bvecs_vec
,
...
...
@@ -373,7 +358,7 @@ void prepare_data_gpu_FIT( //INPUT
if
(
opts
.
grad_file
.
set
()){
for
(
int
vox
=
0
;
vox
<
nvox
;
vox
++
){
correct_bvals_bvecs
(
bvals
,
bvecs
,
gradm
.
Column
(
vox
+
1
),
Qform
,
Qform_inv
,
bvals_vec
[
vox
],
bvecs_vec
[
vox
]);
//correct for gradient nonlinearities
correct_bvals_bvecs
(
bvals
,
bvecs
,
gradm
.
Column
(
vox
+
1
),
bvals_vec
[
vox
],
bvecs_vec
[
vox
]);
//correct for gradient nonlinearities
MISCMATHS
::
cart2sph
(
bvecs_vec
[
vox
],
alpha
,
beta
);
for
(
int
dir
=
0
;
dir
<
NDIRECTIONS
;
dir
++
){
...
...
This diff is collapsed.
Click to expand it.
CUDA/xfibres_gpu.cuh
+
0
−
2
View file @
c38b202c
...
...
@@ -35,8 +35,6 @@ void prepare_data_gpu_FIT( //INPUT
const
Matrix
bvecs
,
const
Matrix
bvals
,
const
Matrix
gradm
,
const
Matrix
Qform
,
const
Matrix
Qform_inv
,
//OUTPUT
vector
<
ColumnVector
>&
datam_vec
,
vector
<
Matrix
>&
bvecs_vec
,
...
...
This diff is collapsed.
Click to expand it.
CUDA/xfibres_gpu.h
+
0
−
2
View file @
c38b202c
...
...
@@ -17,8 +17,6 @@ void xfibres_gpu( //INPUT
const
NEWMAT
::
Matrix
bvals
,
const
NEWMAT
::
Matrix
bvecs
,
const
NEWMAT
::
Matrix
gradm
,
const
NEWMAT
::
Matrix
Qform
,
const
NEWMAT
::
Matrix
Qform_inv
,
const
NEWIMAGE
::
volume
<
int
>
vol2matrixkey
,
const
NEWMAT
::
Matrix
matrix2volkey
,
const
NEWIMAGE
::
volume
<
float
>
mask
,
...
...
This diff is collapsed.
Click to expand it.
xfibres_gpu.cc
+
2
−
24
View file @
c38b202c
...
...
@@ -6,10 +6,6 @@
/* CCOPYRIGHT */
#ifndef EXPOSE_TREACHEROUS
#define EXPOSE_TREACHEROUS
#endif
#include
"CUDA/xfibres_gpu.h"
#include
"xfibresoptions.h"
#include
"newmat.h"
...
...
@@ -22,9 +18,6 @@
using
namespace
Xfibres
;
void
Return_Qform
(
const
Matrix
&
qform_mat
,
Matrix
&
QMat
,
const
float
xdim
,
const
float
ydim
,
const
float
zdim
);
//////////////////////////////////////////////////////////
// XFIBRES CPU PART. IT CALLS TO GPU PART
//////////////////////////////////////////////////////////
...
...
@@ -114,13 +107,10 @@ int xfibres_gpu(char *subjdir,int slice, int nextras, char** extras)
//Samples samples(vol2matrixkey,matrix2volkey,datam.Ncols(),datam.Nrows()); //in xfibres_gpu.cu
//Read Gradient Non_linearity Maps if provided
NEWIMAGE
::
volume4D
<
float
>
grad
;
Matrix
gradm
,
Qform
,
Qform_inv
;
NEWIMAGE
::
volume4D
<
float
>
grad
;
Matrix
gradm
;
if
(
opts
.
grad_file
.
set
()){
read_volume4D
(
grad
,
opts
.
grad_file
.
value
());
gradm
=
grad
.
matrix
(
mask
);
//Get the scale-free Qform matrix to rotate bvecs back to scanner's coordinate system
Return_Qform
(
data
.
qform_mat
(),
Qform
,
data
.
xdim
(),
data
.
ydim
(),
data
.
zdim
());
Qform_inv
=
Qform
.
i
();
}
myfile
<<
"Number of Voxels: "
<<
datam
.
Ncols
()
<<
endl
;
...
...
@@ -129,7 +119,7 @@ int xfibres_gpu(char *subjdir,int slice, int nextras, char** extras)
if
(
opts
.
rician
.
value
()
&&
!
opts
.
nonlin
.
value
())
cout
<<
"Rician noise model requested. Non-linear parameter initialization will be performed, overriding other initialization options!"
<<
endl
;
xfibres_gpu
(
datam
,
bvecs
,
bvals
,
gradm
,
Qform
,
Qform_inv
,
vol2matrixkey
,
matrix2volkey
,
mask
,
slice
,
subjdir
);
xfibres_gpu
(
datam
,
bvecs
,
bvals
,
gradm
,
vol2matrixkey
,
matrix2volkey
,
mask
,
slice
,
subjdir
);
gettimeofday
(
&
t2
,
NULL
);
time
=
timeval_diff
(
&
t2
,
&
t1
);
...
...
@@ -139,15 +129,3 @@ int xfibres_gpu(char *subjdir,int slice, int nextras, char** extras)
return
0
;
}
//Get the scale-free Qform matrix to rotate bvecs back to scanner's coordinate system
//After applying this matrix, make sure to sign flip the x coordinate of the resulted bvecs!
//If you apply the inverse of the matrix, sign flip the x coordinate of the input bvecs
void
Return_Qform
(
const
Matrix
&
qform_mat
,
Matrix
&
QMat
,
const
float
xdim
,
const
float
ydim
,
const
float
zdim
){
Matrix
QMat_tmp
;
DiagonalMatrix
Scale
(
3
);
QMat_tmp
=
qform_mat
.
SubMatrix
(
1
,
3
,
1
,
3
);
Scale
(
1
)
=
xdim
;
Scale
(
2
)
=
ydim
;
Scale
(
3
)
=
zdim
;
QMat_tmp
=
Scale
.
i
()
*
QMat_tmp
;
QMat
=
QMat_tmp
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment