Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenWalnut Core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
44
Issues
44
List
Boards
Labels
Service Desk
Milestones
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
8bc7951c
Commit
8bc7951c
authored
Oct 07, 2010
by
Alexander Wiebel
Browse files
Options
Browse Files
Download
Plain Diff
[MERGE]
parents
4511f655
a3ec2f77
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
39 deletions
+49
-39
src/dataHandler/io/WReaderNIfTI.cpp
src/dataHandler/io/WReaderNIfTI.cpp
+49
-39
No files found.
src/dataHandler/io/WReaderNIfTI.cpp
View file @
8bc7951c
...
...
@@ -115,69 +115,77 @@ boost::shared_ptr< WDataSet > WReaderNIfTI::load()
unsigned
int
order
=
(
(
vDim
==
1
)
?
0
:
1
);
// TODO(all): Does recognize vectors and scalars only so far.
unsigned
int
countVoxels
=
columns
*
rows
*
frames
;
// don't rearrange if this is a time series
if
(
header
->
dim
[
5
]
<=
1
)
try
{
switch
(
header
->
datatype
)
// don't rearrange if this is a time series
if
(
header
->
dim
[
5
]
<=
1
)
{
case
DT_UNSIGNED_CHAR
:
switch
(
header
->
datatype
)
{
std
::
vector
<
unsigned
char
>
data
=
copyArray
(
reinterpret_cast
<
unsigned
char
*
>
(
filedata
->
data
),
countVoxels
,
vDim
);
newValueSet
=
boost
::
shared_ptr
<
WValueSetBase
>
(
new
WValueSet
<
unsigned
char
>
(
order
,
vDim
,
data
,
W_DT_UNSIGNED_CHAR
)
);
break
;
}
case
DT_UNSIGNED_CHAR
:
{
std
::
vector
<
unsigned
char
>
data
=
copyArray
(
reinterpret_cast
<
unsigned
char
*
>
(
filedata
->
data
),
countVoxels
,
vDim
);
newValueSet
=
boost
::
shared_ptr
<
WValueSetBase
>
(
new
WValueSet
<
unsigned
char
>
(
order
,
vDim
,
data
,
W_DT_UNSIGNED_CHAR
)
);
break
;
}
case
DT_SIGNED_SHORT
:
{
std
::
vector
<
int16_t
>
data
=
copyArray
(
reinterpret_cast
<
int16_t
*
>
(
filedata
->
data
),
countVoxels
,
vDim
);
newValueSet
=
boost
::
shared_ptr
<
WValueSetBase
>
(
new
WValueSet
<
int16_t
>
(
order
,
vDim
,
data
,
W_DT_INT16
)
);
break
;
}
{
std
::
vector
<
int16_t
>
data
=
copyArray
(
reinterpret_cast
<
int16_t
*
>
(
filedata
->
data
),
countVoxels
,
vDim
);
newValueSet
=
boost
::
shared_ptr
<
WValueSetBase
>
(
new
WValueSet
<
int16_t
>
(
order
,
vDim
,
data
,
W_DT_INT16
)
);
break
;
}
case
DT_INT32
:
{
std
::
vector
<
int32_t
>
data
=
copyArray
(
reinterpret_cast
<
int32_t
*
>
(
filedata
->
data
),
countVoxels
,
vDim
);
newValueSet
=
boost
::
shared_ptr
<
WValueSetBase
>
(
new
WValueSet
<
int32_t
>
(
order
,
vDim
,
data
,
W_DT_SIGNED_INT
)
);
break
;
}
{
std
::
vector
<
int32_t
>
data
=
copyArray
(
reinterpret_cast
<
int32_t
*
>
(
filedata
->
data
),
countVoxels
,
vDim
);
newValueSet
=
boost
::
shared_ptr
<
WValueSetBase
>
(
new
WValueSet
<
int32_t
>
(
order
,
vDim
,
data
,
W_DT_SIGNED_INT
)
);
break
;
}
case
DT_FLOAT
:
{
std
::
vector
<
float
>
data
=
copyArray
(
reinterpret_cast
<
float
*
>
(
filedata
->
data
),
countVoxels
,
vDim
);
newValueSet
=
boost
::
shared_ptr
<
WValueSetBase
>
(
new
WValueSet
<
float
>
(
order
,
vDim
,
data
,
W_DT_FLOAT
)
);
break
;
}
{
std
::
vector
<
float
>
data
=
copyArray
(
reinterpret_cast
<
float
*
>
(
filedata
->
data
),
countVoxels
,
vDim
);
newValueSet
=
boost
::
shared_ptr
<
WValueSetBase
>
(
new
WValueSet
<
float
>
(
order
,
vDim
,
data
,
W_DT_FLOAT
)
);
break
;
}
case
DT_DOUBLE
:
{
std
::
vector
<
double
>
data
=
copyArray
(
reinterpret_cast
<
double
*
>
(
filedata
->
data
),
countVoxels
,
vDim
);
newValueSet
=
boost
::
shared_ptr
<
WValueSetBase
>
(
new
WValueSet
<
double
>
(
order
,
vDim
,
data
,
W_DT_DOUBLE
)
);
break
;
}
{
std
::
vector
<
double
>
data
=
copyArray
(
reinterpret_cast
<
double
*
>
(
filedata
->
data
),
countVoxels
,
vDim
);
newValueSet
=
boost
::
shared_ptr
<
WValueSetBase
>
(
new
WValueSet
<
double
>
(
order
,
vDim
,
data
,
W_DT_DOUBLE
)
);
break
;
}
default:
wlog
::
error
(
"WReaderNIfTI"
)
<<
"unknown data type "
<<
header
->
datatype
<<
std
::
endl
;
newValueSet
=
boost
::
shared_ptr
<
WValueSetBase
>
();
}
}
}
catch
(
const
std
::
exception
&
e
)
{
nifti_image_free
(
filedata
);
throw
e
;
}
newGrid
=
boost
::
shared_ptr
<
WGridRegular3D
>
(
new
WGridRegular3D
(
columns
,
rows
,
frames
,
convertMatrix
(
header
->
qto_xyz
),
convertMatrix
(
header
->
sto_xyz
),
header
->
dx
,
header
->
dy
,
header
->
dz
)
);
columns
,
rows
,
frames
,
convertMatrix
(
header
->
qto_xyz
),
convertMatrix
(
header
->
sto_xyz
),
header
->
dx
,
header
->
dy
,
header
->
dz
)
);
boost
::
shared_ptr
<
WDataSet
>
newDataSet
;
// known description
std
::
string
description
(
header
->
descrip
);
// TODO(philips): polish WDataSetSegmentation for check in
// if ( !description.compare( "WDataSetSegmentation" ) )
// {
// wlog::debug( "WReaderNIfTI" ) << "Load as segmentation" << std::endl;
// newDataSet = boost::shared_ptr< WDataSet >( new WDataSetSegmentation( newValueSet, newGrid ) );
// }
// else
// TODO(philips): polish WDataSetSegmentation for check in
// if ( !description.compare( "WDataSetSegmentation" ) )
// {
// wlog::debug( "WReaderNIfTI" ) << "Load as segmentation" << std::endl;
// newDataSet = boost::shared_ptr< WDataSet >( new WDataSetSegmentation( newValueSet, newGrid ) );
// }
// else
if
(
!
description
.
compare
(
"WDataSetSphericalHarmonics"
)
)
{
...
...
@@ -359,5 +367,7 @@ boost::shared_ptr< WDataSet > WReaderNIfTI::load()
}
newDataSet
->
setFileName
(
m_fname
);
nifti_image_free
(
filedata
);
return
newDataSet
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment