Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
avwutils
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
avwutils
Commits
eb3bc9fe
Commit
eb3bc9fe
authored
16 years ago
by
Matthew Webster
Browse files
Options
Downloads
Patches
Plain Diff
Some more fireproofing
parent
2ef2d203
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fslcorrecthd.cc
+23
-11
23 additions, 11 deletions
fslcorrecthd.cc
with
23 additions
and
11 deletions
fslcorrecthd.cc
+
23
−
11
View file @
eb3bc9fe
...
...
@@ -4,6 +4,7 @@
// CCOPYRIGHT
#include
"newimage/newimageall.h"
#include
"fslio/fslio.h"
#include
<iostream>
using
namespace
NEWIMAGE
;
...
...
@@ -11,7 +12,7 @@ void print_usage(const string& progname)
{
cout
<<
endl
;
cout
<<
"Usage: fslcorrecthd <input> <output>"
<<
endl
;
cout
<<
" Note th
e input file must be an
uncompressed NIFTI or ANALYZE file"
<<
endl
;
cout
<<
" Note th
at fslcorrecthd only works
uncompressed NIFTI or ANALYZE file
s
"
<<
endl
;
}
int
main
(
int
argc
,
char
*
argv
[])
...
...
@@ -35,39 +36,45 @@ int main(int argc,char *argv[])
//check nifti-libs output versus raw header info
int
offset
=
(
int
)
(
fslio
->
niftiptr
->
iname_offset
-
hdr
->
dime
.
vox_offset
);
int
minft
=
(
int
)
MIN
(
fslio
->
niftiptr
->
iname_offset
,
hdr
->
dime
.
vox_offset
);
cerr
<<
"number of bytes wrong: "
<<
offset
<<
endl
;
cerr
<<
"start at byte location: "
<<
minft
<<
endl
;
cout
<<
"number of bytes wrong: "
<<
offset
<<
endl
<<
"start at byte location: "
<<
minft
<<
endl
;
if
(
offset
==
0
)
{
cout
<<
"No byte correction needed, exiting."
<<
endl
;
return
0
;
}
if
(
FslIsCompressedFileType
(
FslGetFileType
(
fslio
)))
{
cerr
<<
"Error: fslcorrecthd requires uncompressed input"
<<
endl
;
exit
(
1
)
;
return
1
;
}
ifstream
input_file
;
ofstream
output_file
;
char
*
temp
,
*
outputName
;
FslGetHdrImgNames
(
argv
[
2
],
fslio
,
&
temp
,
&
outputName
);
char
byte
[
1
];
input_file
.
open
(
argv
[
1
],
ios
::
in
|
ios
::
binary
);
output_file
.
open
(
argv
[
2
],
ofstream
::
out
|
ofstream
::
binary
);
for
(
int
i
=
1
;
i
<=
minft
;
i
++
)
output_file
.
open
(
outputName
,
ofstream
::
out
|
ofstream
::
binary
);
for
(
int
i
=
1
;
i
<=
minft
;
i
++
)
//Write Header
{
input_file
.
read
(
byte
,
1
);
if
(
input_file
.
eof
())
break
;
output_file
.
write
(
byte
,
1
);
}
for
(
int
i
=
1
;
i
<=
abs
(
offset
)
&&
offset
>
0
;
i
++
)
for
(
int
i
=
1
;
i
<=
abs
(
offset
)
&&
offset
>
0
;
i
++
)
//Pad if we have missing 4 bytes
{
byte
[
0
]
=
0
;
output_file
.
write
(
byte
,
1
);
}
}
for
(
int
i
=
1
;
i
<=
abs
(
offset
)
&&
offset
<
0
;
i
++
)
for
(
int
i
=
1
;
i
<=
abs
(
offset
)
&&
offset
<
0
;
i
++
)
//Read past bad extensions/junk
{
input_file
.
read
(
byte
,
1
);
}
while
(
true
)
while
(
true
)
//Copy the data
{
input_file
.
read
(
byte
,
1
);
if
(
input_file
.
eof
())
break
;
...
...
@@ -75,7 +82,12 @@ int main(int argc,char *argv[])
}
output_file
.
close
();
input_file
.
close
();
return
0
;
system
((
"FSLOUTPUTTYPE=NIFTI; ${FSLDIR}/bin/fslmaths "
+
string
(
outputName
)).
c_str
());
//To clean up header
free
(
temp
);
free
(
outputName
);
free
(
hdr
);
return
0
;
}
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