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
235f3017
Commit
235f3017
authored
24 years ago
by
Mark Jenkinson
Browse files
Options
Downloads
Patches
Plain Diff
Initial revision
parent
ebb549ad
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fslcomplex.cc
+211
-0
211 additions, 0 deletions
fslcomplex.cc
with
211 additions
and
0 deletions
fslcomplex.cc
0 → 100644
+
211
−
0
View file @
235f3017
/* avwcomplex.cc
Mark Jenkinson, FMRIB Image Analysis Group
Copyright (C) 2000 University of Oxford */
/* CCOPYRIGHT */
#include
"newimageall.h"
using
namespace
NEWIMAGE
;
void
print_usage
(
const
string
&
progname
)
{
cerr
<<
"Usage: "
<<
progname
<<
" -realabs complexvol absvol"
<<
" [start [end]]"
<<
endl
;
cerr
<<
" "
<<
progname
<<
" -realphase complexvol phasevol"
<<
" [start [end]]"
<<
endl
;
cerr
<<
" "
<<
progname
<<
" -realpolar complexvol absvol phasevol"
<<
" [start [end]]"
<<
endl
;
cerr
<<
" "
<<
progname
<<
" -realcartesian complexvol realvol"
<<
" imagvol [start [end]]"
<<
endl
;
cerr
<<
" "
<<
progname
<<
" -complex realvol imagvol"
<<
" complexvol [start [end]]"
<<
endl
;
cerr
<<
" "
<<
progname
<<
" -complexsplit source dest"
<<
" [start [end]]"
<<
endl
;
cerr
<<
" "
<<
progname
<<
" -complexmerge source1 source2 dest"
<<
endl
;
}
void
fix_start_and_end
(
int
&
start
,
int
&
end
,
int
mint
,
int
maxt
)
{
if
(
start
<
0
)
{
start
=
mint
;
}
if
(
start
<
mint
)
start
=
mint
;
if
(
start
>
maxt
)
start
=
maxt
;
if
(
end
<
0
)
{
end
=
maxt
;
}
if
(
end
<
mint
)
end
=
mint
;
if
(
end
>
maxt
)
end
=
maxt
;
}
void
realpolar
(
const
string
&
fin
,
const
string
&
fabs
,
const
string
&
fphase
,
int
start
,
int
end
)
{
volume4D
<
float
>
vreal
,
vimag
;
read_complexvolume4D
(
vreal
,
vimag
,
fin
);
fix_start_and_end
(
start
,
end
,
vreal
.
mint
(),
vreal
.
maxt
());
if
(
fabs
.
size
()
>
0
)
{
volume4D
<
float
>
vabs
;
for
(
int
n
=
start
;
n
<=
end
;
n
++
)
{
vabs
.
addvolume
(
abs
(
vreal
[
n
],
vimag
[
n
]));
}
save_volume4D
(
vabs
,
fabs
);
}
if
(
fphase
.
size
()
>
0
)
{
volume4D
<
float
>
vphase
;
for
(
int
n
=
start
;
n
<=
end
;
n
++
)
{
vphase
.
addvolume
(
phase
(
vreal
[
n
],
vimag
[
n
]));
}
save_volume4D
(
vphase
,
fphase
);
}
}
void
realcartesian
(
const
string
&
fin
,
const
string
&
freal
,
const
string
&
fimag
,
int
start
,
int
end
)
{
volume4D
<
float
>
vreal
,
vimag
;
read_complexvolume4D
(
vreal
,
vimag
,
fin
);
fix_start_and_end
(
start
,
end
,
vreal
.
mint
(),
vreal
.
maxt
());
if
(
freal
.
size
()
>
0
)
{
volume4D
<
float
>
vre
;
for
(
int
n
=
start
;
n
<=
end
;
n
++
)
{
vre
.
addvolume
(
vreal
[
n
]);
}
save_volume4D
(
vre
,
freal
);
}
if
(
fimag
.
size
()
>
0
)
{
volume4D
<
float
>
vim
;
for
(
int
n
=
start
;
n
<=
end
;
n
++
)
{
vim
.
addvolume
(
vimag
[
n
]);
}
save_volume4D
(
vim
,
fimag
);
}
}
void
complexsave
(
const
string
&
freal
,
const
string
&
fimag
,
const
string
&
fcomplex
,
int
start
,
int
end
)
{
volume4D
<
float
>
vreal
,
vimag
;
read_volume4D
(
vreal
,
freal
);
read_volume4D
(
vimag
,
fimag
);
fix_start_and_end
(
start
,
end
,
Max
(
vreal
.
mint
(),
vimag
.
mint
()),
Min
(
vreal
.
maxt
(),
vimag
.
maxt
()));
if
(
fcomplex
.
size
()
>
0
)
{
volume4D
<
float
>
vre
,
vim
;
for
(
int
n
=
start
;
n
<=
end
;
n
++
)
{
vre
.
addvolume
(
vreal
[
n
]);
vim
.
addvolume
(
vimag
[
n
]);
}
save_complexvolume4D
(
vre
,
vim
,
fcomplex
);
}
}
void
complexsplit
(
const
string
&
fsource
,
const
string
&
fdest
,
int
start
,
int
end
)
{
volume4D
<
float
>
vreal
,
vimag
;
read_complexvolume4D
(
vreal
,
vimag
,
fsource
);
fix_start_and_end
(
start
,
end
,
Max
(
vreal
.
mint
(),
vimag
.
mint
()),
Min
(
vreal
.
maxt
(),
vimag
.
maxt
()));
if
(
fdest
.
size
()
>
0
)
{
volume4D
<
float
>
vre
,
vim
;
for
(
int
n
=
start
;
n
<=
end
;
n
++
)
{
vre
.
addvolume
(
vreal
[
n
]);
vim
.
addvolume
(
vimag
[
n
]);
}
save_complexvolume4D
(
vre
,
vim
,
fdest
);
}
}
void
complexmerge
(
const
string
&
fsource1
,
const
string
&
fsource2
,
const
string
&
fdest
)
{
volume4D
<
float
>
vr1
,
vi1
,
vr2
,
vi2
;
read_complexvolume4D
(
vr1
,
vi1
,
fsource1
);
read_complexvolume4D
(
vr2
,
vi2
,
fsource2
);
if
(
!
samesize
(
vr1
,
vi1
))
{
cerr
<<
"Could not process image "
<<
fsource1
<<
" correctly."
<<
endl
;
return
;
}
if
(
!
samesize
(
vr2
,
vi2
))
{
cerr
<<
"Could not process image "
<<
fsource2
<<
" correctly."
<<
endl
;
return
;
}
if
(
fdest
.
size
()
>
0
)
{
volume4D
<
float
>
vdr
,
vdi
;
for
(
int
n
=
vr1
.
mint
();
n
<=
vr1
.
maxt
();
n
++
)
{
vdr
.
addvolume
(
vr1
[
n
]);
vdr
.
addvolume
(
vi1
[
n
]);
}
for
(
int
n
=
vr2
.
mint
();
n
<=
vr2
.
maxt
();
n
++
)
{
vdr
.
addvolume
(
vr2
[
n
]);
vdr
.
addvolume
(
vi2
[
n
]);
}
save_complexvolume4D
(
vdr
,
vdi
,
fdest
);
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
Tracer
tr
(
"main"
);
string
progname
=
argv
[
0
];
if
(
argc
<
4
)
{
print_usage
(
progname
);
return
-
1
;
}
string
arg
=
argv
[
1
];
int
start
=-
1
,
end
=-
1
;
if
(
arg
==
"-realabs"
)
{
if
(
argc
<
4
)
{
print_usage
(
progname
);
return
-
1
;
}
if
(
argc
>=
5
)
start
=
atoi
(
argv
[
4
]);
if
(
argc
>=
6
)
end
=
atoi
(
argv
[
5
]);
realpolar
(
argv
[
2
],
argv
[
3
],
""
,
start
,
end
);
}
else
if
(
arg
==
"-realphase"
)
{
if
(
argc
<
4
)
{
print_usage
(
progname
);
return
-
1
;
}
if
(
argc
>=
5
)
start
=
atoi
(
argv
[
4
]);
if
(
argc
>=
6
)
end
=
atoi
(
argv
[
5
]);
realpolar
(
argv
[
2
],
""
,
argv
[
3
],
start
,
end
);
}
else
if
(
arg
==
"-realpolar"
)
{
if
(
argc
<
5
)
{
print_usage
(
progname
);
return
-
1
;
}
if
(
argc
>=
6
)
start
=
atoi
(
argv
[
5
]);
if
(
argc
>=
7
)
end
=
atoi
(
argv
[
6
]);
realpolar
(
argv
[
2
],
argv
[
3
],
argv
[
4
],
start
,
end
);
}
else
if
(
arg
==
"-realcartesian"
)
{
if
(
argc
<
5
)
{
print_usage
(
progname
);
return
-
1
;
}
if
(
argc
>=
6
)
start
=
atoi
(
argv
[
5
]);
if
(
argc
>=
7
)
end
=
atoi
(
argv
[
6
]);
realcartesian
(
argv
[
2
],
argv
[
3
],
argv
[
4
],
start
,
end
);
}
else
if
(
arg
==
"-complex"
)
{
if
(
argc
<
5
)
{
print_usage
(
progname
);
return
-
1
;
}
if
(
argc
>=
6
)
start
=
atoi
(
argv
[
5
]);
if
(
argc
>=
7
)
end
=
atoi
(
argv
[
6
]);
complexsave
(
argv
[
2
],
argv
[
3
],
argv
[
4
],
start
,
end
);
}
else
if
(
arg
==
"-complexsplit"
)
{
if
(
argc
<
4
)
{
print_usage
(
progname
);
return
-
1
;
}
if
(
argc
>=
5
)
start
=
atoi
(
argv
[
4
]);
if
(
argc
>=
6
)
end
=
atoi
(
argv
[
5
]);
complexsplit
(
argv
[
2
],
argv
[
3
],
start
,
end
);
}
else
if
(
arg
==
"-complexmerge"
)
{
if
(
argc
<
5
)
{
print_usage
(
progname
);
return
-
1
;
}
complexmerge
(
argv
[
2
],
argv
[
3
],
argv
[
4
]);
}
else
{
print_usage
(
progname
);
return
-
1
;
}
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