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
03a5edd4
Commit
03a5edd4
authored
20 years ago
by
Mark Jenkinson
Browse files
Options
Downloads
Patches
Plain Diff
Fixed bug in copying info for avwcpgeom
parent
74af0e42
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
avwcpgeom.c
+8
-5
8 additions, 5 deletions
avwcpgeom.c
fsledithd
+40
-2
40 additions, 2 deletions
fsledithd
with
48 additions
and
7 deletions
avwcpgeom.c
+
8
−
5
View file @
03a5edd4
...
@@ -35,7 +35,7 @@ int main(argc,argv)
...
@@ -35,7 +35,7 @@ int main(argc,argv)
char
**
argv
;
char
**
argv
;
{
{
/* struct dsr hdr, hdr2; */
/* struct dsr hdr, hdr2; */
FSLIO
*
src
=
NULL
,
*
dest
=
NULL
;
FSLIO
*
src
=
NULL
,
*
dest
=
NULL
,
*
destcopy
=
NULL
;
short
x
,
y
,
z
,
v
,
copydim
=
1
,
t
,
scode
,
qcode
,
dt
=-
1
;
short
x
,
y
,
z
,
v
,
copydim
=
1
,
t
,
scode
,
qcode
,
dt
=-
1
;
float
vx
,
vy
,
vz
,
tr
;
float
vx
,
vy
,
vz
,
tr
;
int
filetype
;
int
filetype
;
...
@@ -59,6 +59,8 @@ int main(argc,argv)
...
@@ -59,6 +59,8 @@ int main(argc,argv)
/* avw_read_hdr(argv[2],&hdr2,&doswap); */
/* avw_read_hdr(argv[2],&hdr2,&doswap); */
dest
=
FslOpen
(
argv
[
2
],
"r"
);
dest
=
FslOpen
(
argv
[
2
],
"r"
);
destcopy
=
(
FSLIO
*
)
calloc
(
sizeof
(
FSLIO
),
1
);
FslCloneHeader
(
destcopy
,
dest
);
if
((
src
==
NULL
)
||
(
dest
==
NULL
))
{
if
((
src
==
NULL
)
||
(
dest
==
NULL
))
{
perror
(
"Error opening files"
);
perror
(
"Error opening files"
);
...
@@ -70,7 +72,7 @@ int main(argc,argv)
...
@@ -70,7 +72,7 @@ int main(argc,argv)
what will be written. Otherwise there is a segfault when it comes to write. */
what will be written. Otherwise there is a segfault when it comes to write. */
FslGetDim
(
src
,
&
x
,
&
y
,
&
z
,
&
v
);
FslGetDim
(
src
,
&
x
,
&
y
,
&
z
,
&
v
);
nsrcbytes
=
x
*
y
*
z
*
v
*
(
FslGetDataType
(
dest
,
&
t
)
/
8
);
nsrcbytes
=
x
*
y
*
z
*
v
*
(
FslGetDataType
(
dest
,
&
t
)
/
8
);
FslGetDim
(
dest
,
&
x
,
&
y
,
&
z
,
&
v
);
FslGetDim
(
dest
,
&
x
,
&
y
,
&
z
,
&
v
);
/* Also store these values for later */
ndestbytes
=
x
*
y
*
z
*
v
*
(
FslGetDataType
(
dest
,
&
t
)
/
8
);
ndestbytes
=
x
*
y
*
z
*
v
*
(
FslGetDataType
(
dest
,
&
t
)
/
8
);
if
(
nsrcbytes
>
ndestbytes
)
nbytes
=
nsrcbytes
;
else
nbytes
=
ndestbytes
;
if
(
nsrcbytes
>
ndestbytes
)
nbytes
=
nsrcbytes
;
else
nbytes
=
ndestbytes
;
if
(
(
buffer
=
calloc
(
nbytes
,
1
))
==
NULL
)
{
if
(
(
buffer
=
calloc
(
nbytes
,
1
))
==
NULL
)
{
...
@@ -88,7 +90,8 @@ int main(argc,argv)
...
@@ -88,7 +90,8 @@ int main(argc,argv)
/* ...and now reopen destination for writing */
/* ...and now reopen destination for writing */
dest
=
FslXOpen
(
desthdrname
,
"wb"
,
filetype
);
dest
=
FslXOpen
(
desthdrname
,
"wb"
,
filetype
);
FslCloneHeader
(
dest
,
src
);
/* Want the old dest properties - just the geom from the src */
FslCloneHeader
(
dest
,
destcopy
);
/* }}} */
/* }}} */
/* {{{ copy geom */
/* {{{ copy geom */
...
@@ -115,7 +118,7 @@ int main(argc,argv)
...
@@ -115,7 +118,7 @@ int main(argc,argv)
if
(
copydim
)
{
if
(
copydim
)
{
FslGetDim
(
src
,
&
x
,
&
y
,
&
z
,
&
v
);
FslGetDim
(
src
,
&
x
,
&
y
,
&
z
,
&
v
);
FslSetDim
(
src
,
x
,
y
,
z
,
v
);
FslSetDim
(
dest
,
x
,
y
,
z
,
v
);
}
}
/* }}} */
/* }}} */
...
@@ -124,7 +127,7 @@ int main(argc,argv)
...
@@ -124,7 +127,7 @@ int main(argc,argv)
/* if ( doswap ) */
/* if ( doswap ) */
/* swap_hdr(&hdr2); */
/* swap_hdr(&hdr2); */
/* Preserve the datatype */
/* Preserve the datatype
- probably unneccesary now, but left for safety
*/
FslSetDataType
(
dest
,
dt
);
FslSetDataType
(
dest
,
dt
);
FslWriteHeader
(
dest
);
FslWriteHeader
(
dest
);
...
...
This diff is collapsed.
Click to expand it.
fsledithd
+
40
−
2
View file @
03a5edd4
...
@@ -31,6 +31,44 @@ if [ $# -ge 2 ] ; then
...
@@ -31,6 +31,44 @@ if [ $# -ge 2 ] ; then
fi
fi
tmpbase
=
`
${
FSLDIR
}
/bin/tmpnam
`
;
tmpbase
=
`
${
FSLDIR
}
/bin/tmpnam
`
;
${
FSLDIR
}
/bin/avwhd
-x
$1
>
${
tmpbase
}
||
exit
tmpbase2
=
`
${
FSLDIR
}
/bin/tmpnam
`
;
# put in helpful comments at the start
echo
"# AVWEDITHD"
>
${
tmpbase
}
echo
"# This text file contains the header information for an Analyze or Nifti file"
>>
${
tmpbase
}
echo
"# Simply edit this file then save it and the header will be regenerated"
>>
${
tmpbase
}
echo
"# (note: if this editor is vi and you don't know it, quit by typing, in order, ESC Z Z )"
>>
${
tmpbase
}
echo
"# All lines starting with the hash (#) character, like this line, will be ignored"
>>
${
tmpbase
}
echo
"# Ensure that all lines intended to set values take the form: name = 'value' "
>>
${
tmpbase
}
echo
"# Note that if the file is Analyze then many settings will be ignored"
>>
${
tmpbase
}
echo
"# Further note that the filetype cannot be changed by this program"
>>
${
tmpbase
}
echo
"# i.e. changing the nifti_type has no effect"
>>
${
tmpbase
}
echo
" "
>>
${
tmpbase
}
# generate the xml-style header with avwhd
${
FSLDIR
}
/bin/avwhd
-x
$1
|
grep
-v
'/>'
|
grep
-v
'_filename'
|
grep
-v
'[^t]_name'
|
grep
-v
'nvox'
|
grep
-v
'to_ijk'
|
grep
-v
'form_.*orientation'
>
${
tmpbase2
}
# exit if the above didn't generate a decent file
if
[
`
cat
${
tmpbase
}
|
wc
-l
`
-le
1
]
;
then
exit
0
;
fi
# tack onto initial comments
cat
${
tmpbase2
}
>>
${
tmpbase
}
# add stuff before end
echo
"# Many fields require codes to be set (e.g. sform_code, qform_code, intent_code)"
>>
${
tmpbase
}
echo
"# Valid values are:"
>>
${
tmpbase
}
echo
"# sform_code (or qform) :- 0=UNKNOWN, 1=SCANNER_ANAT, 2=ALIGNED_ANAT, 3=TALAIRACH, 4=MNI_152"
>>
${
tmpbase
}
echo
"# xyz_units :- 1=METER, 2=MM, 3=MICRON "
>>
${
tmpbase
}
echo
"# t_units :- 8=SEC, 16=MSEC, 24=USEC, 32=HZ, 40=PPM, 48=RADS"
>>
${
tmpbase
}
echo
"# intent_code :- 0=NONE, 2=CORRELATION, 3=TTEST, 4=FTEST, 5=ZSCORE, 6=CHISQ, ..."
>>
${
tmpbase
}
echo
"# 22=PVAL, 23=LOGPVAL, 24=LOG10PVAL, 1001=ESTIMATE, 1002=LABEL (incl masks)"
>>
${
tmpbase
}
echo
"# Other codes can be found in the
$FSLDIR
/src/niftiio/nifti1.h file"
>>
${
tmpbase
}
echo
" "
>>
${
tmpbase
}
# close the xml-style part
echo
"/>"
>>
${
tmpbase
}
# edit header, reprocess and pass onto avwcreatehd
${
EDITOR
}
${
tmpbase
}
${
EDITOR
}
${
tmpbase
}
${
FSLDIR
}
/bin/avwcreatehd
${
tmpbase
}
$1
cat
${
tmpbase
}
|
grep
-v
'^[ ]*#'
|
grep
-v
'^[ ]*$'
>
${
tmpbase2
}
${
FSLDIR
}
/bin/avwcreatehd
${
tmpbase2
}
$1
/bin/rm
${
tmpbase
}
${
tmpbase2
}
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