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
9ed71a84
Commit
9ed71a84
authored
20 years ago
by
Mark Jenkinson
Browse files
Options
Downloads
Patches
Plain Diff
New versions of avwcreatehd and other minor mods
parent
58e215d7
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
avwcpgeom.c
+3
-2
3 additions, 2 deletions
avwcpgeom.c
avwcreatehd.c
+44
-10
44 additions, 10 deletions
avwcreatehd.c
avwsplit.c
+0
-1
0 additions, 1 deletion
avwsplit.c
with
47 additions
and
13 deletions
avwcpgeom.c
+
3
−
2
View file @
9ed71a84
...
@@ -84,8 +84,9 @@ int main(argc,argv)
...
@@ -84,8 +84,9 @@ int main(argc,argv)
/* {{{ copy geom */
/* {{{ copy geom */
/* memcpy(hdr2.dime.vox_units,hdr.dime.vox_units,4); */
/* memcpy(hdr2.dime.vox_units,hdr.dime.vox_units,4); */
FslGetVoxUnits
(
src
,
thestring
);
/* Note that Get and Set VoxDim work exclusively in mm and sec now */
FslSetVoxUnits
(
dest
,
thestring
);
/* FslGetVoxUnits(src, thestring); */
/* FslSetVoxUnits(dest, thestring); */
/* for(i=0;i<8;i++) */
/* for(i=0;i<8;i++) */
/* { */
/* { */
...
...
This diff is collapsed.
Click to expand it.
avwcreatehd.c
+
44
−
10
View file @
9ed71a84
...
@@ -13,7 +13,7 @@ void usage(void)
...
@@ -13,7 +13,7 @@ void usage(void)
printf
(
"
\n
Usage: avwcreatehd <xsize> <ysize> <zsize> <tsize> <xvoxsize> <yvoxsize> <zvoxsize> <tr> <xorigin> <yorigin> <zorigin> <datatype> <headername> [-r]
\n
"
);
printf
(
"
\n
Usage: avwcreatehd <xsize> <ysize> <zsize> <tsize> <xvoxsize> <yvoxsize> <zvoxsize> <tr> <xorigin> <yorigin> <zorigin> <datatype> <headername> [-r]
\n
"
);
printf
(
" avwcreatehd <nifti_xml_file> <headername> [-r]
\n\n
"
);
printf
(
" avwcreatehd <nifti_xml_file> <headername> [-r]
\n\n
"
);
printf
(
" In all forms, [-r] => reverse byte order (to match byte order in data)
\n
"
);
printf
(
" In all forms, [-r] => reverse byte order (to match byte order in data)
\n
"
);
printf
(
" In the second form, an XML form of nifti header is read (as output by avwhd -
n
)
\n
"
);
printf
(
" In the second form, an XML
-ish
form of nifti header is read (as output by avwhd -
x
)
\n
"
);
printf
(
" Note that stdin is used if '-' is used in place of a filename
\n
"
);
printf
(
" Note that stdin is used if '-' is used in place of a filename
\n
"
);
exit
(
1
);
exit
(
1
);
}
}
...
@@ -22,19 +22,37 @@ void usage(void)
...
@@ -22,19 +22,37 @@ void usage(void)
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
FSLIO
*
fslio
;
FSLIO
*
fslio
;
char
*
buffer
,
*
hdrxml
;
void
*
buffer
=
NULL
;
char
*
hdrxml
,
*
filename
;
int
fileread
=
1
,
filetype
;
int
fileread
=
1
,
filetype
;
long
bufsize
=
0
;
short
x
,
y
,
z
,
v
,
dt
;
if
(
argc
<
2
)
if
(
argc
<
2
)
usage
();
usage
();
if
((
argc
==
3
)
||
(
argc
==
4
))
{
if
((
argc
==
3
)
||
(
argc
==
4
))
{
/* use the XML form of header specification */
/* use the XML form of header specification */
f
slio
=
FslOpen
(
argv
[
2
]
,
"wb"
)
;
f
ilename
=
argv
[
2
];
}
else
{
}
else
{
fslio
=
FslOpen
(
argv
[
13
],
"wb"
);
filename
=
argv
[
13
];
}
/* check if file already exists and if so, read the image contents */
/* also store the size of this buffer for later in case it is wrong */
if
(
FslFileExists
(
filename
))
{
/* buffer = FslReadAllVolumes(fslio,filename); */
fslio
=
FslOpen
(
filename
,
"rb"
);
FslGetDim
(
fslio
,
&
x
,
&
y
,
&
z
,
&
v
);
bufsize
=
x
*
y
*
z
*
v
*
FslGetDataType
(
fslio
,
&
dt
)
/
8
;
buffer
=
(
void
*
)
calloc
(
bufsize
,
1
);
FslReadVolumes
(
fslio
,
buffer
,
v
);
FslClose
(
fslio
);
}
}
fslio
=
FslOpen
(
filename
,
"wb"
);
filetype
=
FslGetFileType
(
fslio
);
filetype
=
FslGetFileType
(
fslio
);
if
(
FslBaseFileType
(
FslGetFileType
(
fslio
))
==
FSL_TYPE_MINC
)
{
if
(
FslBaseFileType
(
FslGetFileType
(
fslio
))
==
FSL_TYPE_MINC
)
{
...
@@ -59,11 +77,13 @@ int main(int argc, char **argv)
...
@@ -59,11 +77,13 @@ int main(int argc, char **argv)
}
else
{
}
else
{
/* read XML form */
/* read XML form */
char
*
newstr
;
char
*
newstr
,
*
oldfname
,
*
oldiname
;
FILE
*
fileptr
=
NULL
;
FILE
*
fileptr
=
NULL
;
if
(
strcmp
(
argv
[
1
],
"-"
)
==
0
)
{
fileread
=
0
;}
if
(
strcmp
(
argv
[
1
],
"-"
)
==
0
)
{
fileread
=
0
;}
newstr
=
(
char
*
)
calloc
(
1
,
10000
);
newstr
=
(
char
*
)
calloc
(
10000
,
1
);
hdrxml
=
(
char
*
)
calloc
(
1
,
65534
);
/* too long, to be safe */
oldfname
=
(
char
*
)
calloc
(
10000
,
1
);
oldiname
=
(
char
*
)
calloc
(
10000
,
1
);
hdrxml
=
(
char
*
)
calloc
(
65534
,
1
);
/* too long, to be safe */
if
(
fileread
)
{
if
(
fileread
)
{
fileptr
=
fopen
(
argv
[
1
],
"rb"
);
fileptr
=
fopen
(
argv
[
1
],
"rb"
);
...
@@ -83,11 +103,19 @@ int main(int argc, char **argv)
...
@@ -83,11 +103,19 @@ int main(int argc, char **argv)
strcat
(
hdrxml
,
newstr
);
strcat
(
hdrxml
,
newstr
);
}
while
(
strcmp
(
newstr
+
strlen
(
newstr
)
-
2
,
"/>"
)
!=
0
);
}
while
(
strcmp
(
newstr
+
strlen
(
newstr
)
-
2
,
"/>"
)
!=
0
);
strcpy
(
oldfname
,
fslio
->
niftiptr
->
fname
);
strcpy
(
oldiname
,
fslio
->
niftiptr
->
iname
);
fslio
->
niftiptr
=
nifti_image_from_ascii
(
hdrxml
);
fslio
->
niftiptr
=
nifti_image_from_ascii
(
hdrxml
);
if
(
fslio
->
niftiptr
==
NULL
)
{
if
(
fslio
->
niftiptr
==
NULL
)
{
fprintf
(
stderr
,
"Incomplete or incorrect text: could not form header info
\n
"
);
fprintf
(
stderr
,
"Incomplete or incorrect text: could not form header info
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
fslio
->
niftiptr
->
fname
=
oldfname
;
fslio
->
niftiptr
->
iname
=
oldiname
;
free
(
hdrxml
);
free
(
hdrxml
);
if
(
fileread
)
fclose
(
fileptr
);
if
(
fileread
)
fclose
(
fileptr
);
}
}
...
@@ -108,9 +136,15 @@ int main(int argc, char **argv)
...
@@ -108,9 +136,15 @@ int main(int argc, char **argv)
/* write header */
/* write header */
FslWriteHeader
(
fslio
);
FslWriteHeader
(
fslio
);
/* make a zero image here */
/* if previously read buffer is wrong size then make a zero image here */
buffer
=
(
char
*
)
calloc
(
fslio
->
niftiptr
->
nvox
,
fslio
->
niftiptr
->
nbyper
);
FslGetDim
(
fslio
,
&
x
,
&
y
,
&
z
,
&
v
);
if
(
bufsize
!=
(
x
*
y
*
z
*
v
*
FslGetDataType
(
fslio
,
&
dt
)
/
8
)
)
{
if
(
bufsize
>
0
)
free
(
buffer
);
/* only if previously read */
buffer
=
(
void
*
)
calloc
(
x
*
y
*
z
*
v
,
FslGetDataType
(
fslio
,
&
dt
)
/
8
);
}
/* write the data out - either from previous read or zeros */
FslWriteVolumes
(
fslio
,
buffer
,
fslio
->
niftiptr
->
dim
[
4
]);
FslWriteVolumes
(
fslio
,
buffer
,
fslio
->
niftiptr
->
dim
[
4
]);
FslClose
(
fslio
);
FslClose
(
fslio
);
...
...
This diff is collapsed.
Click to expand it.
avwsplit.c
+
0
−
1
View file @
9ed71a84
...
@@ -39,7 +39,6 @@ int main(int argc, char **argv)
...
@@ -39,7 +39,6 @@ int main(int argc, char **argv)
FslGetDim
(
src
,
&
x
,
&
y
,
&
z
,
&
v
);
FslGetDim
(
src
,
&
x
,
&
y
,
&
z
,
&
v
);
FslGetVoxDim
(
src
,
&
vx
,
&
vy
,
&
vz
,
&
tr
);
FslGetVoxDim
(
src
,
&
vx
,
&
vy
,
&
vz
,
&
tr
);
FslGetVoxUnits
(
src
,
units
);
bufsz
=
x
*
y
*
z
*
(
FslGetDataType
(
src
,
&
t
)
/
8
);
bufsz
=
x
*
y
*
z
*
(
FslGetDataType
(
src
,
&
t
)
/
8
);
buffer
=
(
void
*
)
calloc
(
bufsz
,
sizeof
(
char
));
buffer
=
(
void
*
)
calloc
(
bufsz
,
sizeof
(
char
));
...
...
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