debian/0000755000000000000000000000000012254047757007203 5ustar debian/xmedcon.dirs0000644000000000000000000000002212214301204011465 0ustar usr/share/pixmaps debian/control0000644000000000000000000000673012254047523010603 0ustar Source: xmedcon Maintainer: Debian Med Packaging Team Uploaders: Roland Marcus Rutschmann , Andreas Tille Section: graphics Priority: optional Build-Depends: debhelper (>= 9), libgtk2.0-dev, zlib1g-dev, libpng-dev, libnifti-dev, autotools-dev, dh-autoreconf Standards-Version: 3.9.4 Vcs-Browser: http://anonscm.debian.org/viewvc/debian-med/trunk/packages/xmedcon/trunk/ Vcs-Svn: svn://anonscm.debian.org/debian-med/trunk/packages/xmedcon/trunk/ Homepage: http://xmedcon.sourceforge.net/ Package: libmdc2 Architecture: any Section: libs Depends: ${shlibs:Depends}, ${misc:Depends} Conflicts: libmdc Replaces: libmdc Description: Medical Image (DICOM, ECAT, ...) conversion tool (library) This project stands for Medical Image Conversion. Released under the (L)GPL, it comes with the full C-source code of the library, a flexible command line utility and a neat graphical front-end using the GTK+ toolkit. The currently supported formats are: Acr/Nema 2.0, Analyze (SPM), DICOM 3.0, InterFile 3.3 and PNG. . This is the central library needed by medcon, xmedcon and derived programs. Package: libmdc2-dev Architecture: any Section: libdevel Depends: libmdc2 (= ${binary:Version}), ${misc:Depends} Conflicts: libmdc-dev Replaces: libmdc-dev Description: Medical Image (DICOM, ECAT, ...) conversion tool (development) This project stands for Medical Image Conversion. Released under the (L)GPL, it comes with the full C-source code of the library, a flexible command line utility and a neat graphical front-end using the GTK+ toolkit. The currently supported formats are: Acr/Nema 2.0, Analyze (SPM), DICOM 3.0, InterFile 3.3 and PNG. . Static library, include files and documentation for developers. Package: medcon Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Suggests: xmedcon Description: Medical Image (DICOM, ECAT, ...) conversion tool This project stands for Medical Image Conversion. Released under the (L)GPL, it comes with the full C-source code of the library, a flexible command line utility and a neat graphical front-end using the GTK+ toolkit. The currently supported formats are: Acr/Nema 2.0, Analyze (SPM), DICOM 3.0, InterFile 3.3 and PNG. . The program also allows one to read unsupported files without compression, to print pixel values or to extract/reorder specified images. It is possible to retrieve the raw binary/ascii image arrays or to write PNG for desktop applications. . This is the command line tool for batch processing. Package: xmedcon Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Recommends: medcon Description: Medical Image (DICOM, ECAT, ...) conversion tool (GUI) This project stands for Medical Image Conversion. Released under the (L)GPL, it comes with the full C-source code of the library, a flexible command line utility and a neat graphical front-end using the GTK+ toolkit. The currently supported formats are: Acr/Nema 2.0, Analyze (SPM), DICOM 3.0, InterFile 3.3 and PNG. . The program also allows one to read unsupported files without compression, to print pixel values or to extract/reorder specified images. It is possible to retrieve the raw binary/ascii image arrays or to write PNG for desktop applications. . This is the program version for X based on GTK+. Processes only one file at a time. debian/README.source0000644000000000000000000000141012214301204011326 0ustar xmedcon for Debian ------------------ The source of xmedcon contains some third party libraries: libs/nifti: Nifti-1 C libraries This code is not used because (x)medcon is linked against the Debian packaged version. Please also read the description of debian/patches/legal-dummies.patch which contains the original patches done by Roland Marcus Rutschmann wo claimed that "The code handling ecat format had to be removed for legal reasons." This needs to be clarified and the patch needs to be acticated or deactivated. In case it turns out that even the source could can not be distributed the source tarball needs to be stripped and the patch needs to be adapted to reinject the missing files. -- Andreas Tille Tue, 23 Jul 2013 08:46:18 +0200 debian/libmdc2-dev.install0000644000000000000000000000036412214301204012636 0ustar debian/tmp/usr/lib/*/*.a debian/tmp/usr/lib/*/*.so debian/tmp/usr/include debian/tmp/usr/share/man/man1/xmedcon-config.1 debian/tmp/usr/share/man/man3 debian/tmp/usr/share/man/man4 debian/tmp/usr/share/aclocal debian/tmp/usr/bin/xmedcon-config debian/xmedcon.xpm0000644000000000000000000000266412214301204011346 0ustar /* XPM */ static char *xmedcon1[] = { /* columns rows colors chars-per-pixel */ "32 32 14 1", " c black", ". c #191919", "X c gray20", "o c #7F0000", "O c #7F7F00", "+ c #4C4C4C", "@ c #666667", "# c gray50", "$ c yellow", "% c gray60", "& c #B2B2B2", "* c gray80", "= c gray90", "- c None", /* pixels */ "----------------------O---------", "---------------------+#---------", "---------------------O----------", "-----------------O---+----------", "-----------------O--@-----------", "----------------@+--@-----------", "----------------+---++X+--------", "----------------X---oO.+--------", "--------------oO---..X. X@------", "------------@++----XX.o. @----@O", "------------@XO#--@X.oo -O@O#-", "----------++#-XXXoo. ...XX------", "--------+X-#X#--+XO ...O--------", "-------@X#--++-.XX .+---OXXO#--", "---@O+..----#+XOo....#--O O-----", "---------@oXX++. .X+XX%#X-------", "-------+XX@+o. ..X--XX.+-------", "------O+--XOO. ++----XX--------", "-----#X--o+o. ..X+o----@--------", "-----XO-+OX.o....-.O------------", "---@++--+.o .X.+ -#.#-----------", "-@.@----.o..o.XXX--XO-----------", "+X------....XX- --+X------------", "--------+..+#--X--+#------------", "-------------O.+-.#-------------", "--------- --X.+.-+.-. ..--- ..--", "---------.+X -. .. --.-..--.-", "---------- .-- .X -- - -----", "----------X -- ... --.-.-----", "---------- .- -- -- - -----", "---------.--. . -- . -. -- --.-", "---------X-----------.-.--------" }; debian/rules0000755000000000000000000000102112214301204010225 0ustar #!/usr/bin/make -f # -*- makefile -*- # debian/rules file for xmedcon # Andreas Tille # GPL %: dh $@ --with autotools_dev --with autoreconf override_dh_auto_configure: dh_auto_configure -- --enable-nifti --with-nifti-prefix=/usr override_dh_auto_install: dh_auto_install cp -a debian/xmedcon.xpm $(CURDIR)/debian/xmedcon/usr/share/pixmaps/ -test -r $(CURDIR)/debian/tmp/etc/xmedcon.png && \ cp -f $(CURDIR)/debian/tmp/etc/xmedcon.png \ $(CURDIR)/debian/xmedcon/usr/share/icons/hicolor/48x48/apps/ debian/watch0000644000000000000000000000006612214301204010206 0ustar version=3 http://sf.net/xmedcon/xmedcon-(.*)\.tar\.gz debian/copyright0000644000000000000000000001222112214301204011104 0ustar Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: (X)MedCon Upstream-Contact: Erik Nolf Source: http://xmedcon.sourceforge.net/Main/Download Files: * Copyright: © 1997-2013 Erik Nolf License: GPL-2+ Files: libs/dicom/* Copyright: © 1998-2002 Tony Voet © 2002-2009 Erik Nolf License: LGPL-2.1+ Files: libs/dicom/dict-dicom.dic Copyright: © 1994-2005 Andrew Hewett, Marco Eichelberg (OFFIS) © 2006 Erik Nolf License: OFFISdicom This software and supporting documentation were developed by . Kuratorium OFFIS e.V. Healthcare Information and Communication Systems Escherweg 2 D-26121 Oldenburg, Germany . THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND OFFIS MAKES NO WARRANTY REGARDING THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH THE USER. . Copyright of the software and supporting documentation is, unless otherwise stated, owned by OFFIS, and free access is hereby granted as a license to use this software, copy this software and prepare derivative works based upon this software. However, any distribution of this software source code or supporting documentation or derivative works (source code and supporting documentation) must include the three paragraphs of this copyright notice. Files: libs/ljpg/* Copyright: © 2002 Jaslet Bertrand © 2002-2009 Erik Nolf License: LGPL-2.1+ Files: libs/nifti/* Copyright: none License: other nifticlib was written by the NIfTI Data Format Working Group (DFWG, http://nifti.nimh.nih.gov/). The NIFTI DFWG disclaims all copyright in nifticlib and places it in the public domain. Comment: This source is not used because the package building process is linking against the Debian packaged version of libnifti-dev Files: libs/tpc/ecat7*.* Copyright: © 2005-2013 by Turku PET Centre License: LGPL-2.1+ Comment: This is a stripped down version from the Turku PET Centre libraries The whole set of files can be downloaded from http://www.turkupetcentre.net/software/libsrc/libtpcimgio_2_1_8_src.zip Files: libs/tpc/petc99.* libs/tpc/swap.* Copyright: © 2000-2005 by Turku PET Centre License: LGPL-2.1+ Comment: This is a stripped down version from the Turku PET Centre libraries The whole set of files can be downloaded from http://www.turkupetcentre.net/programs/libpet_src.zip Files: source/m-qmedian.c: Copyright: © 1988-1997 Sam Leffler © 1991-1997 Silicon Graphics, Inc. License: SClicense "Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that (i) the above copyright notices and this permission notice appear in all copies of the software and related documentation, and (ii) the names of Sam Leffler and Silicon Graphics may not be used in any advertising or publicity relating to the software without the specific, prior written permission of Sam Leffler and Silicon Graphics." Comment: code was adapted from 'tiffmedian.c' (see http://www.libtiff.org) Files: debian/* Copyright: © 2002-2010 Roland Marcus Rutschmann © 2013 Andreas Tille License: GPL-2+ License: LGPL-2.1+ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. . This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. . You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . On Debian systems you can find a full copy of LGPL 2.1+ at /usr/share/common-licenses/LGPL-2.1 . License: GPL-2+ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. . This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. . You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. . On Debian systems you can find a full copy of GPL 2+ at /usr/share/common-licenses/GPL-2 . debian/source/0000755000000000000000000000000012254043512010464 5ustar debian/source/format0000644000000000000000000000001412214301204011661 0ustar 3.0 (quilt) debian/README.Debian0000644000000000000000000000027312214301204011216 0ustar xmedcon for Debian ------------------ The complete Documentation can be found at: http://xmedcon.sourceforge.net/ -- Andreas Tille Tue, 23 Jul 2013 08:46:18 +0200 debian/medcon.docs0000644000000000000000000000004512214301204011271 0ustar REMARKS debian/Readme.siemens_mosaic debian/xmedcon.mime0000644000000000000000000000022412214301204011457 0ustar application/dicom; /usr/bin/xmedcon --enable-contrast --enable-mosaic -f '%s'; test=test -n "$DISPLAY";description=DICOM Image; nametemplate=%s.dcm debian/changelog0000644000000000000000000003314512254044351011046 0ustar xmedcon (0.13.0-2) unstable; urgency=medium * Fix typo in package description Closes: #589573 * Verified proposed patch to build with libpng 1.5 and realise that the new upstream version Closes: #649795 (Thanks to Nobuhiro Iwamatsu for his patch anyway) -- Andreas Tille Tue, 17 Dec 2013 13:37:32 +0100 xmedcon (0.13.0-1) unstable; urgency=low * New upstream version Closes: #704438 * debian/control: - Add Vcs fields - Add Homepage field - Team maintenance in Debian Med team - cme fix dpkg-control Closes: #662563 * debian/source/format: 3.0 (quilt) * debian/watch: version=3 * debian/libmdc2-dev.install: Drop *.la file Closes: #633237 * debian/patches/man-spelling.patch: Enhance manpages syntax and spelling * debian/patches/code-spelling.patch: Fix spelling in library * debian/README.Debian: Removed now invalid information * debian/README.source: Add basic information about potential legal issues of ecat7 format * debian/copyright: DEP5 copyright * debian/patches/legal-dummies.patch: Restore the patches done by Roland Marcus Rutschmann except for gif format which is legal these days * debian/patches/avoid_linking_to_unneeded_libs.patch: Avoid useless linking against GTK library for command line tool Closes: #632163 -- Andreas Tille Tue, 23 Jul 2013 08:46:18 +0200 xmedcon (0.10.7-1) unstable; urgency=low * New upstream release * Bumped Standards-Version to 3.9.1 -- Roland Marcus Rutschmann Thu, 14 Oct 2010 10:32:22 +0000 xmedcon (0.10.5-2.1) unstable; urgency=low * Non-maintainer upload. * Work around bug #519006 by passing -g0 to the compiler on mips and mipsel (closes: #590612). -- Jakub Wilk Fri, 13 Aug 2010 11:04:27 +0200 xmedcon (0.10.5-2) unstable; urgency=low * closes: #589881 (changed builddep to libnifti-dev from libnifti1-dev) * Bumped Standards-Version to 3.9.0 -- Roland Marcus Rutschmann Sun, 25 Jul 2010 12:04:16 +0000 xmedcon (0.10.5-1) unstable; urgency=low * New upstream release * Changed menu section from viewers to science/medicine * Bumped Standards-Version to 3.8.2 -- Roland Marcus Rutschmann Mon, 13 Jul 2009 19:58:05 +0000 xmedcon (0.10.4-1) unstable; urgency=low * New upstream release -- Roland Marcus Rutschmann Thu, 20 Mar 2008 16:30:00 +0000 xmedcon (0.10.2-1) unstable; urgency=low * New upstream release * closes: #460373 (changed builddep to libnifti1-dev from libniftiio1-dev) * Fixed lintian warning 'description-contains-homepage' and moved homepage from Description to Homepage field for the package. * Bumped Standards-Version to 3.7.3 * Removed NEWS file wich is kept up on upstreams web-page * moved xmedcon.xpm and Readme.siemens_mosaic to debian directory to keep all changes to this directory -- Roland Marcus Rutschmann Sat, 05 Jan 2008 15:43:57 +0000 xmedcon (0.10.1-1) unstable; urgency=low * New upstream release * redid the changes from 0.9.1 leaving the source nifti libs configure and Makefile from upstream untouched to keep more compatible with upstream. libmdc is still linked against debians libnifti1 * changed build-dependancies to libgtk-2.0-dev -- Roland Marcus Rutschmann Thu, 29 Nov 2007 16:11:55 +0000 xmedcon (0.9.10-2) unstable; urgency=low * closes: #449032 (added dh_icons to rules to adjust to ubuntu source) * closes: #450312 (updated debian/watch file to new website) * closes: #450589 (patched xmedcon.m4 with quotes for AC_DEFUN to work with automake-1.9 -- Roland Marcus Rutschmann Thu, 08 Nov 2007 09:45:06 +0000 xmedcon (0.9.10-1) unstable; urgency=low * New upstream release * removed nifti libs from source as they are packaged in debian allready * patched ./configure and libs/Makefile.in to not fail after removal of libs/nifti -- Roland Marcus Rutschmann Wed, 26 Sep 2007 10:57:23 +0200 xmedcon (0.9.9.7-1) unstable; urgency=low * New upstream release -- Roland Marcus Rutschmann Mon, 24 Sep 2007 11:07:10 +0200 xmedcon (0.9.9.6.2-1) unstable; urgency=low * New upstream release * fixed dist-clean rule in debian/rules as suggested by lintian * changed dependencies to libniftiio1-dev to allow nifti files >2GB * changed menu entry from Apps to Applications -- Roland Marcus Rutschmann Fri, 21 Sep 2007 16:57:35 +0200 xmedcon (0.9.9.6-1) unstable; urgency=low * New upstream release -- Roland Marcus Rutschmann Mon, 16 Jul 2007 17:20:16 +0200 xmedcon (0.9.9.5.1-1) unstable; urgency=low * New upstream release -- Roland Marcus Rutschmann Fri, 06 Jul 2007 15:55:02 +0200 xmedcon (0.9.9.4-2) unstable; urgency=low * Add xmedcon as viewer to /etc/mailcap * closes: #407016 (asking for that) -- Roland Marcus Rutschmann Fri, 19 Jan 2007 21:13:10 +0100 xmedcon (0.9.9.4-1) unstable; urgency=low * New upstream release * closes: #401529 (Segmentation fault when processing compressed jpeg DICOM) * better support for nifti headers in debian -- Roland Marcus Rutschmann Wed, 13 Dec 2006 14:40:46 +0000 xmedcon (0.9.9.3-3) unstable; urgency=low * put libniftiio0-dev in builddep (stupid mistake :-( ) * closes: #402152 (FTBFS: checking for NIFTI package) -- Roland Marcus Rutschmann Fri, 8 Dec 2006 16:27:02 +0100 xmedcon (0.9.9.3-2) unstable; urgency=low * really include nifti support with change to rules and configure, forgot in v-1 :-( -- Roland Marcus Rutschmann Tue, 5 Dec 2006 11:44:28 +0100 xmedcon (0.9.9.3-1) unstable; urgency=low * New upstream release * limited nifti support. Build depends on libniftiio0-dev now * bumped to standards 3.7.2 -- Roland Marcus Rutschmann Mon, 2 Oct 2006 13:27:48 +0200 xmedcon (0.9.9.0-1) unstable; urgency=low * New upstream release -- Roland Marcus Rutschmann Mon, 19 Dec 2005 21:02:43 +0100 xmedcon (0.9.8.7-1) unstable; urgency=low * New upstream release -- Roland Marcus Rutschmann Mon, 10 Oct 2005 19:34:15 +0000 xmedcon (0.9.8.6-1) unstable; urgency=low * New upstream release -- Roland Marcus Rutschmann Wed, 3 Aug 2005 20:08:55 +0200 xmedcon (0.9.8.5-1) unstable; urgency=low * New upstream release -- Roland Marcus Rutschmann Mon, 23 May 2005 11:54:09 +0200 xmedcon (0.9.8.4-1) unstable; urgency=low * New upstream release * Removed dh_changelog as no changelog is included upstream anymore -- Roland Marcus Rutschmann Thu, 17 Feb 2005 11:47:33 +0100 xmedcon (0.9.8.1-1) unstable; urgency=low * New upstream release -- Roland Marcus Rutschmann Thu, 11 Nov 2004 15:53:37 +0100 xmedcon (0.9.7.3-1) unstable; urgency=low * New upstream release -- Roland Marcus Rutschmann Thu, 16 Sep 2004 16:14:14 +0200 xmedcon (0.9.7.2-2) unstable; urgency=low * accidentially uploaded woody backported sources in 0.9.7.2-1 * changed icon path back to /usr/share/pixmaps -- Roland Marcus Rutschmann Mon, 9 Aug 2004 15:39:01 +0200 xmedcon (0.9.7.2-1) unstable; urgency=low * New upstream release closes: #262145 (New upstream release available 0.9.7.2) -- Roland Marcus Rutschmann Thu, 5 Aug 2004 20:26:54 +0200 xmedcon (0.9.6-1) unstable; urgency=low * New upstream release closes: #252687 (New upstream release available 0.9.6) * Changed Build-Dependancy (again) to libpng12-dev -- Roland Marcus Rutschmann Mon, 7 Jun 2004 09:00:14 +0200 xmedcon (0.9.3-1) unstable; urgency=low * New upstream release -- Roland Marcus Rutschmann Tue, 30 Mar 2004 11:56:23 +0200 xmedcon (0.9.1-1) unstable; urgency=low * New upstream release -- Roland Marcus Rutschmann Wed, 21 Jan 2004 12:46:38 +0100 xmedcon (0.9.0-1) unstable; urgency=low * New upstream release * Adapted headers of dummy-versions of m-gif.c and m-ecat*.c in debian's orig.tar.gz to headers of version 0.9.0 -- Roland Marcus Rutschmann Mon, 5 Jan 2004 20:21:50 +0100 xmedcon (0.8.13a-2) unstable; urgency=low * Bumped to standards 3.6.1 * Changed Build-Dependancy to libpng2-dev (see README.Debian) and debhelper to version > 4.0.0 * Removed libc6-dev dependency from libmdc2-dev (redundancy with build-depends) * Cleaned up rules a bit (deleting some dh_* calls, replacing dh_movefile with dh_install) -- Roland Marcus Rutschmann Mon, 5 Jan 2004 10:29:20 +0100 xmedcon (0.8.13a-1) unstable; urgency=low * fixed the orig.tar.gz source (patent related patches see README.Debian) -- Roland Marcus Rutschmann Fri, 31 Oct 2003 10:17:40 +0100 xmedcon (0.8.13-1) unstable; urgency=low * New upstream release * Bumped to standards 3.5.10 (no changes needed) -- Roland Marcus Rutschmann Mon, 16 Jun 2003 10:33:23 +0200 xmedcon (0.8.11-1) unstable; urgency=low * New upstream release * Upstream now uses autoconf-2.57, automake-1.7.4 & libtool-1.5 closes: #190233 -- Roland Marcus Rutschmann Mon, 28 Apr 2003 17:54:45 +0200 xmedcon (0.8.9-1) unstable; urgency=low * New upstream release * changed maintainer's email-address to reflect the debian signed address * update standards to 3.5.9 * reduced icon to 16 colors to satisfy lintian * moved libmdc to Section libs * moved libmdc-dev to Section libdevel * included Homepage in description (devel-ref 6.2.4) * renamed libmdc* to libmdc2 to satisfy library so naming convention -- Roland Marcus Rutschmann Wed, 16 Apr 2003 17:48:00 +0200 xmedcon (0.8.8-1) unstable; urgency=low * New upstream release * changed copyrights file to include all copyrights * included new (V2) Copyrights for ljpeglib by Cornell University -- Roland Marcus Rutschmann Thu, 12 Dec 2002 08:58:57 +0100 xmedcon (0.8.7-1) unstable; urgency=low * New upstream release -- Roland Marcus Rutschmann Tue, 19 Nov 2002 16:11:59 +0100 xmedcon (0.8.6-2) unstable; urgency=low * Removed 2 references to GIF Format in control-file -- Roland Marcus Rutschmann Tue, 19 Nov 2002 15:34:07 +0100 xmedcon (0.8.6-1) unstable; urgency=low * New upstream release * First official Debian package closes: #141352 * incorporate better dummy versions for non-GPL modules (see README.Debian) * Standards-Version: 3.5.7 (changed by Andreas Tille ) * Minor spelling fixes in README.Debian (changed by Andreas Tille ) * Added xmedcon.xpm icon acording to the policy of menu package and changed menu entry accordingly (changed by Andreas Tille ) -- Roland Marcus Rutschmann Mon, 18 Nov 2002 23:18:44 +0100 xmedcon (0.8.5-1) unstable; urgency=low * New upstream release -- Roland Marcus Rutschmann Wed, 13 Nov 2002 20:37:04 +0100 xmedcon (0.8.4-3) unstable; urgency=low * removed license-problematic code from source and binaries -- Roland Marcus Rutschmann Wed, 13 Nov 2002 18:16:42 +0100 xmedcon (0.8.4-2) unstable; urgency=low * updated build-debends * (x)medcon depends on same version libmdc -- Roland Marcus Rutschmann Mon, 11 Nov 2002 19:09:08 +0100 xmedcon (0.8.4-1) unstable; urgency=low * New upstream release -- Roland Marcus Rutschmann Mon, 4 Nov 2002 20:58:21 +0100 xmedcon (0.8.1-1) unstable; urgency=low * New upstream release -- Roland Marcus Rutschmann Wed, 9 Oct 2002 17:43:36 +0200 xmedcon (0.8.0-1) unstable; urgency=low * New upstream release -- Roland Marcus Rutschmann Wed, 11 Sep 2002 15:49:13 +0200 xmedcon (0.7.9-1) unstable; urgency=low * New upstream release -- Roland Marcus Rutschmann Mon, 10 Jun 2002 14:45:36 +0200 xmedcon (0.7.8-1) unstable; urgency=low * New upstream release -- Roland Marcus Rutschmann Tue, 14 May 2002 18:25:11 +0200 xmedcon (0.7.7-1) unstable; urgency=low * New upstream release -- Roland Marcus Rutschmann Tue, 30 Apr 2002 14:42:40 +0200 xmedcon (0.7.5-1) unstable; urgency=low * New upstream release * upstream's manpage for xmedcon-config included * upstream's icon for xmedcon included in xmedcon.menu -- Roland Marcus Rutschmann Wed, 27 Mar 2002 17:10:10 +0100 xmedcon (0.7.4-3) unstable; urgency=low * split into 4 packages -- Roland Marcus Rutschmann Thu, 21 Mar 2002 18:27:43 +0100 xmedcon (0.7.4-2) unstable; urgency=low * added a quick Bugfix from Eric Nolf for m-acr.c * added copyright notice for gif and ecat -- Roland Marcus Rutschmann Fri, 8 Mar 2002 13:18:52 +0100 xmedcon (0.7.4-1) unstable; urgency=low * Initial Release. * added NEWS frome http://xmedcon.sourceforge.net/new/ -- Roland Marcus Rutschmann Mon, 4 Mar 2002 21:42:01 +0100 debian/patches/0000755000000000000000000000000012254044203010611 5ustar debian/patches/legal-dummies.patch0000644000000000000000000061012612214301204014356 0ustar Author: Roland Marcus Rutschmann LastChanged: Thu, 14 Oct 2010 10:32:22 +0000 Description: THIS PATCH IS NOT ACTIVATED The former maintainer of this package Roland Marcus Rutschmann has put the following text into README.Debian: . The code handling ecat format had to be removed for legal reasons. The following files from the original source code where replaced by mostly empty dummies: . m-ecat64.c + m-ecat64.h m-ecat72.c + m-ecat72.h m-matrix.c + m-matrix.h . Remark of Andreas Tille (Debian Med team): The author also replaced m-gif.[ch] which is definitely not needed any more and so this patch was not incorporated. Moreover because it is not clear what "legal reasons" here are suspected the patch is deactivated for the moment but keep here in case it will be really needed --- a/source/m-ecat64.c +++ b/source/m-ecat64.c @@ -7,28 +7,18 @@ * * * project : (X)MedCon by Erik Nolf * * * - * Functions : MdcCheckECAT6() - Check for ECAT 6.4 format * - * MdcReadECAT6() - Read ECAT 6.4 file * - * MdcWriteECAT6() - Write ECAT 6.4 file * - * MdcGetSliceLocation() - Get slice location * - * MdcGetFilterCode() - Get code number of filter * - * MdcFillMainHeader() - Fill in Main Header * - * MdcFillImageSubHeader() - Fill in Image SubHeader * - * MdcPrintEcatInfoDB() - Print ECAT database info * + * Functions : MdcCheckECAT() - Check for ECAT format * + * MdcReadECAT() - Read ECAT 6.4 file * + * MdcWriteECAT() - Write ECAT 6.4 file * * * - * * - * Notes : source needs m-matrix.h & m-matrix.c * - * * - * Credits : - CTI coders - for creating the basic code * - * - Johan Keppens - getting it to work initially * - * - Sakari Alenius - reading using a matrix list * + * Notes : DEBIAN - code removed due to unclear licensing * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* $Id: m-ecat64.c,v 1.89 2013/06/23 21:51:19 enlf Exp $ +/* - debian dummy file v0.2 - */ /* - Copyright (C) 1997-2013 by Erik Nolf + Copyright (C) 1997-2002 by Erik Nolf This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -66,1282 +56,20 @@ #include "medcon.h" /**************************************************************************** - D E F I N E S -****************************************************************************/ - -#define MDC_NUM_BEDS_TWEAK MDC_YES /* check on zero/one based num_beds */ - -#ifdef _WIN32 -#define MDC_ECAT6_RESTRICT_DIMS MDC_YES /* only square dim and max 256 (safe) */ -#else -#define MDC_ECAT6_RESTRICT_DIMS MDC_NO /* no square dim and no max (danger) */ -#endif - -static Uint32 saved_mwidth; -static Uint32 saved_mheight; - -static char MdcEcatDataTypes - [MDC_MAX_ECATDATATYPES][MDC_MAX_ECATDATATYPES_SIZE]= - {"Unknown","ByteData","VAX Int16","VAX Int32", - "VAX float","IEEE float","SUN Int16","SUN Int32"}; -static char MdcEcatFileTypes - [MDC_MAX_ECATFILETYPES][MDC_MAX_ECATFILETYPES_SIZE]= - {"Unknown","Sinogram","PetImage","Attenuation", - "Normalization","Smooth File"}; -static char MdcEcatAcquisitionTypes - [MDC_MAX_ECATACQTYPES][MDC_MAX_ECATACQTYPES_SIZE]= - {"Undefined","Blank","Transmission", - "Static Emission","Dynamic Emission","Gated Emission", - "Transmission Rectilinear","Emission Rectilinear", - "Whole Body Transmission","Whole Body Static"}; - -static char MdcEcatFilterTypes - [MDC_MAX_ECATFLTRTYPES][MDC_MAX_ECATFLTRTYPES_SIZE]= - {"None","Ramp","Butter","Hann", - "Hamm","Parzen","Shepp","Unknown"}; - -static char MdcEcatQuantificationUnits - [MDC_MAX_ECATQUANTTYPES][MDC_MAX_ECATQUANTTYPES_SIZE]= - {"Total Counts","Undefined", - "ECAT counts/second/pixel","uCi/ml [1uCi = 37Bq]", - "LMRGlu","LMRGlu umol/min/100g","LMRGlu mg/min/100g", - "nCi/ml","Well counts","Becquerels","ml/min/100g", - "ml/min/g"}; - -static Int16 MdcEcatSystemTypes[MDC_MAX_ECATSYSTEMTYPES]= - {831, 911, 931, 933, 951, 953}; - -/**************************************************************************** F U N C T I O N S ****************************************************************************/ int MdcCheckECAT6(FILEINFO *fi) -{ - Mdc_Main_header mh; - int i; - - if (mdc_mat_read_main_header(fi->ifp,&mh)) return MDC_BAD_READ; - - if (mh.system_type == MDC_ECAT6_SYST_TYPE) return MDC_FRMT_ECAT6; - - for (i=0; i < MDC_MAX_ECATSYSTEMTYPES; i++) { - if (mh.system_type == MdcEcatSystemTypes[i]) - return MDC_FRMT_ECAT6; - } - - return MDC_FRMT_NONE; - -} - - -const char *MdcReadECAT6(FILEINFO *fi) -{ - FILE *fp = fi->ifp; - IMG_DATA *id=NULL; - DYNAMIC_DATA *dd=NULL; - int i, error; - const char *err; - char *str; - Uint32 bytes, img=0, found=0, number; - Mdc_Main_header mh; - Mdc_Image_subheader ish; - Mdc_Scan_subheader ssh; - Mdc_Attn_subheader ash; - Mdc_Norm_subheader nsh; - struct Mdc_MatDir entry, matrix_list[MDC_ECAT6_MAX_MATRICES]; - struct Mdc_Matval matval; - Int16 data_type=BIT16_S; - int bed,gate,frame,plane,data=0,nb,ng,nf,np,nd; - int matnum, startblk, endblk, num_matrices; - float slice_position; - - if (MDC_PROGRESS) MdcProgress(MDC_PROGRESS_BEGIN,0.,"Reading ECAT6:"); - - if (MDC_VERBOSE) MdcPrntMesg("ECAT6 Reading <%s> ...",fi->ifname); - - /* put some defaults we use */ - fi->endian=MDC_FILE_ENDIAN=MDC_LITTLE_ENDIAN; - fi->modality = M_PT; - - /* read the main header */ - error = mdc_mat_read_main_header(fp, &mh); - if (error) return("ECAT6 Bad read main header"); - -/* - if (MDC_INFO_DB) { - MdcPrintEcatInfoDB(&mh); - return NULL; - } -*/ - - if (MDC_INFO || MDC_INFO_DB) { - - MdcPrntScrn("Main Header (%d bytes)\n",MH_64_SIZE); - MdcPrintLine('-',MDC_HALF_LENGTH); - - MdcPrntScrn("Original Filename : "); - MdcPrintStr(mh.original_file_name); - MdcPrntScrn("Software Version : %d\n",mh.sw_version); - MdcPrntScrn("Data Type : %d ",mh.data_type); - if ((mh.data_type > -1) && (mh.data_type < 8)) - MdcPrntScrn("(= %s)\n",MdcEcatDataTypes[mh.data_type]); - else - MdcPrntScrn("(= Unknown)\n"); - MdcPrntScrn("System Type : %d\n",mh.system_type); - MdcPrntScrn("File Type : %d ",mh.file_type); - if ((mh.file_type > -1) && (mh.file_type < 5)) - MdcPrntScrn("(= %s)\n",MdcEcatFileTypes[mh.file_type]); - else - MdcPrntScrn("(= Unknown)\n"); - MdcPrntScrn("Node Id : "); MdcPrintStr(mh.node_id); - MdcPrntScrn("Scan Date - Day : %d\n",mh.scan_start_day); - MdcPrntScrn(" - Month : %d\n",mh.scan_start_month); - MdcPrntScrn(" - Year : %d\n",mh.scan_start_year); - MdcPrntScrn(" - Hour : %d\n",mh.scan_start_hour); - MdcPrntScrn(" - Minute : %d\n",mh.scan_start_minute); - MdcPrntScrn(" - Second : %d\n",mh.scan_start_second); - MdcPrntScrn("Isotope Code : "); MdcPrintStr(mh.isotope_code); - MdcPrntScrn("Isotope Halflife : %f [sec]\n",mh.isotope_halflife); - MdcPrntScrn("Radiopharmaceutical : "); - MdcPrintStr(mh.radiopharmaceutical); - MdcPrntScrn("Gantry Tilt : %f [degrees]\n",mh.gantry_tilt); - MdcPrntScrn("Gantry Rotation : %f [degrees]\n" - ,mh.gantry_rotation); - MdcPrntScrn("Bed Elevation : %f [cm]\n",mh.bed_elevation); - MdcPrntScrn("Rotating Source Speed : %d [revolutions/minute]\n" - ,mh.rot_source_speed); - MdcPrntScrn("Wobble Control Speed : %d [revolutions/minute]\n" - ,mh.wobble_speed); - MdcPrntScrn("Transmission Source : %d\n",mh.transm_source_type); - MdcPrntScrn("Axial Field of View : %f [cm]\n",mh.axial_fov); - MdcPrntScrn("Transaxial Field of View : %f [cm]\n",mh.transaxial_fov); - MdcPrntScrn("Transaxial Sampling Mode : %d\n",mh.transaxial_samp_mode); - MdcPrntScrn("Coincidence Sampling Mode: %d\n",mh.coin_samp_mode); - MdcPrntScrn("Axial Sampling Mode : %d\n",mh.axial_samp_mode); - MdcPrntScrn("Calibration Factor : %f\n",mh.calibration_factor); - MdcPrntScrn("Calibration Units : %d ",mh.calibration_units); - if ((mh.calibration_units > -1) && (mh.calibration_units < 12)) - MdcPrntScrn("(= %s)\n" - ,MdcEcatQuantificationUnits[mh.calibration_units]); - else - MdcPrntScrn("(= Unknown)\n"); - MdcPrntScrn("Compression Code : %d\n",mh.compression_code); - MdcPrntScrn("Study Name : "); MdcPrintStr(mh.study_name); - MdcPrntScrn("Patient Id : "); MdcPrintStr(mh.patient_id); - MdcPrntScrn("Patient Name : "); MdcPrintStr(mh.patient_name); - MdcPrntScrn("Patient Sex : "); MdcPrintChar(mh.patient_sex); - MdcPrntScrn("\n"); - MdcPrntScrn("Patient Age : "); MdcPrintStr(mh.patient_age); - MdcPrntScrn("Patient Height : "); - MdcPrintStr(mh.patient_height); - MdcPrntScrn("Patient Weight : "); - MdcPrintStr(mh.patient_weight); - MdcPrntScrn("Patient Dexterity : "); - MdcPrintChar(mh.patient_dexterity); - MdcPrntScrn("\n"); - MdcPrntScrn("Physician Name : "); - MdcPrintStr(mh.physician_name); - MdcPrntScrn("Operator Name : "); - MdcPrintStr(mh.operator_name); - MdcPrntScrn("Study Description : "); - MdcPrintStr(mh.study_description); - MdcPrntScrn("Acquisition Type : %d ",mh.acquisition_type); - if ((mh.acquisition_type > -1) && (mh.acquisition_type <= 9)) - MdcPrntScrn("(= %s)\n",MdcEcatAcquisitionTypes[mh.acquisition_type]); - else - MdcPrntScrn("(= Unknown)\n"); - MdcPrntScrn("Bed Type : %d\n",mh.bed_type); - MdcPrntScrn("Septa Type : %d\n",mh.septa_type); - MdcPrntScrn("Facility Name : "); MdcPrintStr(mh.facility_name); - MdcPrntScrn("Number of Planes : %d\n",mh.num_planes); - MdcPrntScrn("Number of Frames : %d\n",mh.num_frames); - MdcPrntScrn("Number of Gates : %d\n",mh.num_gates); - MdcPrntScrn("Number of Bed Positions : %d\n",mh.num_bed_pos); - MdcPrntScrn("Initial Bed Position : %f [cm]\n",mh.init_bed_position); - for (i=0; i<15; i++) - MdcPrntScrn("Bed Offset[%02d] : %f [cm]\n",i+1 - ,mh.bed_offset[i]); - MdcPrntScrn("Plane Separation : %f [cm]\n",mh.plane_separation); - MdcPrntScrn("Lower Scatter Treshold : %d [KeV]\n",mh.lwr_sctr_thres); - MdcPrntScrn("Lower True Treshold : %d [KeV]\n",mh.lwr_true_thres); - MdcPrntScrn("Upper True Treshold : %d [KeV]\n",mh.upr_true_thres); - MdcPrntScrn("Collimator : %6.0f\n",mh.collimator); - MdcPrntScrn("User Process Code : "); - MdcPrintStr(mh.user_process_code); - MdcPrntScrn("Acquisition Mode : %d\n",mh.acquisition_mode); - - } - - if (MDC_INFO_DB) return(NULL); /* just needed db info */ - - if ((mh.file_type!=MDC_ECAT6_SCAN_FILE) && - (mh.file_type!=MDC_ECAT6_IMAGE_FILE) && - (mh.file_type!=MDC_ECAT6_ATTN_FILE) && - (mh.file_type!=MDC_ECAT6_NORM_FILE) ) - return("ECAT6 Unsupported file type"); - - if (mh.num_frames <= 0 ) mh.num_frames = 1; - if (mh.num_gates <= 0 ) mh.num_gates = 1; - if (mh.num_bed_pos < 0 ) mh.num_bed_pos = 0; - - /* fill in global FILEINFO data */ - fi->dim[0]= 6; - fi->dim[3]= mh.num_planes; - fi->dim[4]= mh.num_frames; - fi->dim[5]= mh.num_gates; - fi->dim[6]= mh.num_bed_pos + 1; /* must be 1-based */ - -#if MDC_NUM_BEDS_TWEAK - /* double check num_bed_pos value due to */ - /* inconsistent use as zero or one based */ - bed = mh.num_bed_pos; - while (!mdc_mat_lookup(fp,mdc_mat_numcod(1,1,1,0,bed),&entry) && (bed > 0)) { - bed--; - } - fi->dim[6] = bed + 1; -#endif - - /* check for unsupported bed overlap */ - if (fi->dim[6] > 1) { - float axial_width, bed_offset=mh.bed_offset[0]; - - if (bed_offset < 0) bed_offset = -bed_offset; - - axial_width = mh.plane_separation * (float)fi->dim[3]; - if ((axial_width - bed_offset) >= 1.0) { - MdcPrntWarn("ECAT6 Bed overlaps unsupported"); - } - } - - for (i=3, number=1; i<=6; i++) number*=fi->dim[i]; - - if (number == 0) return("ECAT6 No valid images specified"); - - /* fill in orientation information */ - fi->pat_slice_orient = MDC_SUPINE_HEADFIRST_TRANSAXIAL; /* default! */ - str = MdcGetStrPatPos(fi->pat_slice_orient); - MdcStringCopy(fi->pat_pos,str,strlen(str)); - - if ( (strncmp(mh.user_process_code,"COR",10)==0) || - (strncmp(mh.user_process_code,"SAG",10)==0)) { - /* CORONAL SLICES or SAGITTAL SLICES - The images Ecat 6.4 software writes are useless: - 128x128 images with the small coronal/sagittal slice in it ... - This means their pixel_xsize & pixel_ysize doesn't quite - fit the real world dimensions any more !! - Therefore we don't even try to attempt writing the proper - orientation information. - */ - }else{ - /* "TRA" or nothing - TRANSAXIAL SLICES (Transverse) - Writing the proper orientation information - See man-page `m-acr.4' for more info (!) - */ - str = MdcGetStrPatOrient(fi->pat_slice_orient); - MdcStringCopy(fi->pat_orient,str,strlen(str)); - } - - /* fill in patient study related information */ - fi->patient_sex[0] = mh.patient_sex; fi->patient_sex[1]='\0'; - MdcStringCopy(fi->patient_name,mh.patient_name,32); - MdcStringCopy(fi->patient_id,mh.patient_id,16); - fi->patient_weight = (float)atof(mh.patient_weight); - fi->patient_height = (float)atof(mh.patient_height); - fi->study_date_day = mh.scan_start_day; - fi->study_date_month = mh.scan_start_month; - fi->study_date_year = mh.scan_start_year; - fi->study_time_hour = mh.scan_start_hour; - fi->study_time_minute= mh.scan_start_minute; - fi->study_time_second= mh.scan_start_second; - - if ((mh.file_type==MDC_ECAT6_SCAN_FILE) || - (mh.file_type==MDC_ECAT6_IMAGE_FILE)) { - switch (mh.acquisition_type) { - case MDC_ECAT6_ACQTYPE_UNKNOWN : - fi->acquisition_type = MDC_ACQUISITION_UNKNOWN; break; - case MDC_ECAT6_ACQTYPE_BLANK : - fi->acquisition_type = MDC_ACQUISITION_UNKNOWN; break; - case MDC_ECAT6_ACQTYPE_TRANSMISSION : - fi->acquisition_type = MDC_ACQUISITION_TOMO; break; - case MDC_ECAT6_ACQTYPE_STATIC_EMISSION : - fi->acquisition_type = MDC_ACQUISITION_TOMO; break; - case MDC_ECAT6_ACQTYPE_DYNAMIC_EMISSION : - fi->acquisition_type = MDC_ACQUISITION_DYNAMIC; break; - case MDC_ECAT6_ACQTYPE_GATED_EMISSION : - fi->acquisition_type = MDC_ACQUISITION_GSPECT; break; - case MDC_ECAT6_ACQTYPE_TRANSMISSION_RECT : - fi->acquisition_type = MDC_ACQUISITION_UNKNOWN; break; - case MDC_ECAT6_ACQTYPE_EMISSION_RECT : - fi->acquisition_type = MDC_ACQUISITION_UNKNOWN; break; - case MDC_ECAT6_ACQTYPE_WHOLE_BODY_TRANSM : - fi->acquisition_type = MDC_ACQUISITION_UNKNOWN; break; - case MDC_ECAT6_ACQTYPE_WHOLE_BODY_STATIC : - fi->acquisition_type = MDC_ACQUISITION_TOMO; break; - default: - fi->acquisition_type = MDC_ACQUISITION_UNKNOWN; - } - }else{ - fi->acquisition_type = MDC_ACQUISITION_UNKNOWN; - } - sprintf(mdcbufr,"ECAT%hd",mh.system_type); - MdcStringCopy(fi->manufacturer,mdcbufr,strlen(mdcbufr)); - MdcStringCopy(fi->operator_name,mh.operator_name,32); - MdcStringCopy(fi->study_descr,mh.study_description,32); - MdcStringCopy(fi->study_id,mh.study_name,12); - MdcStringCopy(fi->institution,mh.facility_name,20); - MdcStringCopy(fi->radiopharma,mh.radiopharmaceutical,32); - MdcStringCopy(fi->isotope_code,mh.isotope_code,8); - - fi->isotope_halflife = mh.isotope_halflife; - fi->gantry_tilt = mh.gantry_tilt; - - if (MDC_ECHO_ALIAS == MDC_YES) { - MdcEchoAliasName(fi); return(NULL); - } - - if (!MdcGetStructID(fi,number)) - return("ECAT6 Bad malloc IMG_DATA structs"); - - /* always malloc dyndata structs */ - if (!MdcGetStructDD(fi,(Uint32)fi->dim[4]*fi->dim[5]*fi->dim[6])) - return("ECAT6 Couldn't malloc DYNAMIC_DATA structs"); - - /* always malloc beddata structs */ - if (!MdcGetStructBD(fi,(unsigned)fi->dim[6])) - return("ECAT6 Couldn't malloc BED_DATA structs"); - - /* fill in BED_DATA struct */ - fi->beddata[0].hoffset = mh.init_bed_position * 10.; /* mm */ - fi->beddata[0].voffset = mh.bed_elevation * 10.; /* mm */ - for (i=1; ibednr; i++) { - fi->beddata[i].hoffset = mh.init_bed_position + mh.bed_offset[i-1]; - fi->beddata[i].hoffset *= 10.; /* mm */ - - fi->beddata[i].voffset = mh.bed_elevation * 10.; /* mm */ - } - - /* ECAT6: matrices for each slice */ - num_matrices = mdc_mat_list(fp, matrix_list, MDC_ECAT6_MAX_MATRICES); - if (num_matrices == 0) - return("ECAT6 No matrices found"); - if ((Uint32)num_matrices > fi->number) - return("ECAT6 Too many matrices found"); - - /* sort matrices */ - if ( num_matrices > 1) { - - switch (MDC_ECAT6_SORT) { - - case MDC_ANATOMICAL: /* anatomical */ - bed = fi->dim[6]; /* one based */ - if (fi->dim[4] > 1) { - mdc_plane_sort(matrix_list, num_matrices); - }else{ - mdc_anatomical_sort(matrix_list, num_matrices, &mh, bed); - } - break; - case MDC_BYFRAME : /* by frame */ - mdc_matnum_sort(matrix_list, num_matrices); - break; - } - - } - - for (bed=0; beddim[6]; bed++) - for (gate=1; gate<=fi->dim[5]; gate++) - for (frame=1; frame<=fi->dim[4]; frame++) - for (plane=1; plane<=fi->dim[3]; plane++) { - - if (MDC_PROGRESS) MdcProgress(MDC_PROGRESS_INCR,1./(float)fi->number,NULL); - - if (img == (Uint32)num_matrices) break; - - if (fi->dynnr > 0) dd = &fi->dyndata[(fi->dim[4]*bed) + (frame-1)]; - - mdc_mat_numdoc(matrix_list[img].matnum,&matval); - nf = matval.frame; np = matval.plane; ng = matval.gate; - nb = matval.bed; nd = matval.data; - matnum = mdc_mat_numcod(nf,np,ng,nd,nb); - if (!mdc_mat_lookup(fp, matnum, &entry)) continue; - startblk = entry.strtblk + 1; - endblk = entry.endblk - entry.strtblk; - - switch (mh.file_type) { - - case MDC_ECAT6_SCAN_FILE: - - error = mdc_mat_read_scan_subheader(fp, startblk-1, &ssh); - if (error) return("ECAT6 Bad read scan subheader"); - if (MDC_INFO) { - MdcPrintLine('-',MDC_FULL_LENGTH); - MdcPrntScrn("SINOGRAM SUBHEADER %05d: ",img+1); - MdcPrntScrn("Frame: %d Plane: %d Gate: %d Data: %d Bed: %d\n" - ,frame,plane,gate,data,bed); - MdcPrintLine('-',MDC_FULL_LENGTH); - MdcPrntScrn("Data Type : %d ",ssh.data_type); - if ((ssh.data_type > -1) && (ssh.data_type < 8)) - MdcPrntScrn("(= %s)\n",MdcEcatDataTypes[ssh.data_type]); - else - MdcPrntScrn("(= Unknown)\n"); - MdcPrntScrn("Number of Elements : %d (width)\n",ssh.dimension_1); - MdcPrntScrn("Number of Views : %d (height)\n",ssh.dimension_2); - MdcPrntScrn("Smoothing : %d ",ssh.smoothing); - switch (ssh.smoothing) { - case 0: MdcPrntScrn("(= Not Smoothed)\n"); break; - case 1: MdcPrntScrn("(= 9x9 Smoothing)\n"); break; - default: MdcPrntScrn("(= Unknown)\n"); - } - MdcPrntScrn("Processing Code : %d\n",ssh.processing_code); - MdcPrntScrn("Sample Distance : %f [cm]\n",ssh.sample_distance); - MdcPrntScrn("Isotope Halflife : %f [sec]\n",ssh.isotope_halflife); - MdcPrntScrn("Frame Duration (sec): %d [sec]\n" - ,ssh.frame_duration_sec); - MdcPrntScrn("Gate Duration : %d [ms]\n",ssh.gate_duration); - MdcPrntScrn("R-Wave Offset : %d [ms]\n",ssh.r_wave_offset); - MdcPrntScrn("Scale factor : %f\n",ssh.scale_factor); - MdcPrntScrn("Minimum Scan Value : %d\n",ssh.scan_min); - MdcPrntScrn("Maximum Scan Value : %d\n",ssh.scan_max); - MdcPrntScrn("Total Prompts : %d\n",ssh.prompts); - MdcPrntScrn("Total Delayed Events: %d\n",ssh.delayed); - MdcPrntScrn("Total Multiples : %d\n",ssh.multiples); - MdcPrntScrn("Total Net Trues : %d (Prompts - Random)\n" - ,ssh.net_trues); - for (i=0; i<16; i++) - MdcPrntScrn("Corrected Singles [%2d] : %f\n",i+1 - ,ssh.cor_singles[i]); - for (i=0; i<16; i++) - MdcPrntScrn("Uncorrected Singles [%2d] : %f\n",i+1 - ,ssh.uncor_singles[i]); - MdcPrntScrn("Total Average Corrected Singles: %f\n" - ,ssh.tot_avg_cor); - MdcPrntScrn("Total Average Uncorrected Singles: %f\n" - ,ssh.tot_avg_uncor); - MdcPrntScrn("Total Coincidence Rage : %d (from IPCP)\n" - ,ssh.total_coin_rate); - MdcPrntScrn("Frame Start Time : %d [ms]\n" - ,ssh.frame_start_time); - MdcPrntScrn("Frame Duration : %d [ms]\n" - ,ssh.frame_duration); - MdcPrntScrn("Loss Correction Factor : %f\n" - ,ssh.loss_correction_fctr); - for (i=0; i<8; i++) MdcPrntScrn("Phy_Planes [%d] : %d\n",i+1 - ,ssh.phy_planes[i]); - } - - /* fill in DYNAMIC_DATA struct */ - if ((dd != NULL) && (plane == (fi->dim[3]/2))) { - /* take values from a plane halfway */ - dd->nr_of_slices = fi->dim[3]; - dd->time_frame_start = (float)ssh.frame_start_time; - dd->time_frame_duration = (float)ssh.frame_duration; - } - - /* fill in IMG_DATA struct */ - id = &fi->image[img]; - id->width = (Uint32)ssh.dimension_1; - id->height = (Uint32)ssh.dimension_2; - - id->quant_units = 1; - id->quant_scale = 1; - id->calibr_units= 1; - id->calibr_fctr = 1; - - id->quant_scale = ssh.scale_factor; - - id->pixel_xsize = id->pixel_ysize = ssh.sample_distance * 10.;/* mm */ - data_type = ssh.data_type; - switch( data_type ) { - case BYTE_TYPE: id->bits = 8; id->type = BIT8_U; break; - case M68K_I2 : - /* case SUN_I2 : */ - case VAX_I2 : id->bits =16; id->type = BIT16_S; break; - case M68K_I4 : - /* case SUN_I4 : */ - case VAX_I4 : id->bits =32; id->type = BIT32_S; break; - case IEEE_R4 : - /* case SUN_R4 : */ - case VAX_R4 : id->bits =32; id->type = FLT32; break; - } - - break; - - case MDC_ECAT6_IMAGE_FILE: - - error = mdc_mat_read_image_subheader(fp, startblk-1, &ish); - if (error) return("ECAT6 Bad read image subheader"); - if (MDC_INFO) { - MdcPrintLine('-',MDC_FULL_LENGTH); - MdcPrntScrn("IMAGE SUBHEADER %05d: ",img+1); - MdcPrntScrn("Frame: %d Plane: %d Gate: %d Data: %d Bed: %d\n" - ,frame,plane,gate,data,bed); - MdcPrintLine('-',MDC_FULL_LENGTH); - - MdcPrntScrn("Data Type : %d ",ish.data_type); - if ((ish.data_type > -1) && (ish.data_type < 8)) - MdcPrntScrn("(= %s)\n",MdcEcatDataTypes[ish.data_type]); - else - MdcPrntScrn("(= Unknown)\n"); - MdcPrntScrn("Number of Dimensions : %d\n",ish.num_dimensions); - MdcPrntScrn("X Dimension : %d\n",ish.dimension_1); - MdcPrntScrn("Y Dimension : %d\n",ish.dimension_2); - MdcPrntScrn("X Offset : %f [cm]\n",ish.x_origin); - MdcPrntScrn("Y Offset : %f [cm]\n",ish.y_origin); - MdcPrntScrn("Recon Magnification Factor : %f\n",ish.recon_scale); - MdcPrntScrn("Quantification Scale Factor : %e\n",ish.quant_scale); - MdcPrntScrn("Image Minimum Pixel Value : %d\n",ish.image_min); - MdcPrntScrn("Image Maximum Pixel Value : %d\n",ish.image_max); - MdcPrntScrn("Pixel Size : %f [cm]\n",ish.pixel_size); - MdcPrntScrn("Slice Width : %f [cm]\n",ish.slice_width); - MdcPrntScrn("Frame Duration : %d [ms]\n",ish.frame_duration); - MdcPrntScrn("Frame Start Time : %d [ms]\n",ish.frame_start_time); - MdcPrntScrn("Slice Location : %d [cm]\n",ish.slice_location); - MdcPrntScrn("Recon Start Hour : %d\n",ish.recon_start_hour); - MdcPrntScrn("Recon Start Minute : %d\n",ish.recon_start_minute); - MdcPrntScrn("Recon Start Second : %d\n",ish.recon_start_sec); - MdcPrntScrn("Gate Duration : %d [ms]\n",ish.gate_duration); - MdcPrntScrn("Filter code : %d ",ish.filter_code); - ish.filter_code = abs(ish.filter_code); - if ((ish.filter_code > -1) && (ish.filter_code < 7)) - MdcPrntScrn("(= %s)\n",MdcEcatFilterTypes[ish.filter_code]); - else - MdcPrntScrn("(= Unknown)\n"); - MdcPrntScrn("Scan Matrix Number : %d\n",ish.scan_matrix_num); - MdcPrntScrn("Normalization Matrix Number : %d\n",ish.norm_matrix_num); - MdcPrntScrn("Attenuation Matrix Number : %d\n" - ,ish.atten_cor_matrix_num); - MdcPrntScrn("Image Rotation : %f [degrees]\n" - ,ish.image_rotation); - MdcPrntScrn("Plane Efficiency Correction Factor: %f\n" - ,ish.plane_eff_corr_fctr); - MdcPrntScrn("Decay Correction Factor : %f\n",ish.decay_corr_fctr); - MdcPrntScrn("Loss Correction Factor : %f\n",ish.loss_corr_fctr); - MdcPrntScrn("Processing Code : %d\n",ish.processing_code); - MdcPrntScrn("Quantification Units : %d ",ish.quant_units); - if ((ish.quant_units > -1) && (ish.quant_units < 13)) - MdcPrntScrn("(= %s)\n",MdcEcatQuantificationUnits[ish.quant_units]); - else - MdcPrntScrn("(= Unknown)\n"); - MdcPrntScrn("Reconstruction Start Day : %d\n",ish.recon_start_day); - MdcPrntScrn("Reconstruction Start Month : %d\n" - ,ish.recon_start_month); - MdcPrntScrn("Reconstruction Start Year : %d\n" - ,ish.recon_start_year); - MdcPrntScrn("Ecat Calibration Factor : %f\n" - ,ish.ecat_calibration_fctr); - MdcPrntScrn("Well Counter Calibribration Factor : %f\n" - ,ish.well_counter_cal_fctr); - MdcPrntScrn("Filter Params - Cutoff Frequency : %f\n" - ,ish.filter_params[0]); - MdcPrntScrn("Filter Params - DC Component : %f\n" - ,ish.filter_params[1]); - MdcPrntScrn("Filter Params - Ramp Slope : %f\n" - ,ish.filter_params[2]); - MdcPrntScrn("Filter Params - (4) : %f\n" - ,ish.filter_params[3]); - MdcPrntScrn("Filter Params - Scatter Comp 1 : %f\n" - ,ish.filter_params[4]); - MdcPrntScrn("Filter Params - Scatter Comp 2 : %f\n" - ,ish.filter_params[5]); - MdcPrntScrn("Annotation : "); MdcPrintStr(ish.annotation); - - } - - /* fill in DYNAMIC_DATA struct */ - if ((dd != NULL) && (plane == (fi->dim[3]/2))) { - /* take values from a plane halfway */ - dd->nr_of_slices = fi->dim[3]; - dd->time_frame_start = (float)ish.frame_start_time; - dd->time_frame_duration = (float)ish.frame_duration; - } - - /* fill in IMG_DATA struct */ - - id = &fi->image[img]; - id->width = (Uint32)ish.dimension_1; - id->height = (Uint32)ish.dimension_2; - id->recon_scale = ish.recon_scale; - - id->quant_units = ish.quant_units; - id->quant_scale = ish.quant_scale; - id->calibr_units= mh.calibration_units; - id->calibr_fctr = ish.ecat_calibration_fctr; - - id->pixel_xsize = id->pixel_ysize = ish.pixel_size * 10.; /* in mm */ - id->slice_width = ish.slice_width * 10.; /* in mm */ - data_type = ish.data_type; - switch( data_type ) { - case BYTE_TYPE: id->bits = 8; id->type = BIT8_U; break; - case M68K_I2 : - /* case SUN_I2 : */ - case VAX_I2 : id->bits =16; id->type = BIT16_S; break; - case M68K_I4 : - /* case SUN_I4 : */ - case VAX_I4 : id->bits =32; id->type = BIT32_S; break; - case IEEE_R4 : - /* case SUN_R4 : */ - case VAX_R4 : id->bits =32; id->type = FLT32; break; - } - - id->slice_spacing = mh.plane_separation*10.; /* separation in mm */ - - if ( (strncmp(mh.user_process_code,"COR",10)==0) || - (strncmp(mh.user_process_code,"SAG",10)==0)) { - /* CORONAL SLICES or SAGITTAL SLICES - The images Ecat 6.4 software writes are useless: - 128x128 images with the small coronal/sagittal slice in it ... - This means their pixel_xsize & pixel_ysize doesn't quite - fit the real world dimensions any more !! - Therefore we don't even try to attempt writing the proper - Acr/Nema variables ... - */ - }else{ /* "TRA" or nothing */ - /* TRANSAXIAL SLICES (Transverse) */ - /* Writing the proper Acr/Nema variables ... */ - /* See man-page `m-acr.4' for more info (!) */ - - /* slice position with bed offset (mm) */ - if (bed == 0) { - slice_position = mh.init_bed_position; - }else{ - slice_position = mh.init_bed_position + mh.bed_offset[bed-1]; - } - slice_position *= 10.; /* mm */ - - MdcFillImgPos(fi,img,(Uint32)(plane-1),slice_position); - MdcFillImgOrient(fi,img); - - } - - break; - - case MDC_ECAT6_ATTN_FILE: - - error = mdc_mat_read_attn_subheader(fp, startblk-1, &ash); - if (error) return("ECAT6 Bad read attenuation subheader"); - if (MDC_INFO) { - - MdcPrintLine('-',MDC_FULL_LENGTH); - MdcPrntScrn("ATTENUATION SUBHEADER %05d: ",img+1); - MdcPrntScrn("Frame: %d Plane: %d Gate: %d Data: %d Bed: %d\n" - ,frame,plane,gate,data,bed); - MdcPrintLine('-',MDC_FULL_LENGTH); - MdcPrntScrn("Data Type : %d ",ash.data_type); - if ((ash.data_type > -1) && (ash.data_type < 8)) - MdcPrntScrn("(= %s)\n",MdcEcatDataTypes[ash.data_type]); - else - MdcPrntScrn("(= Unknown)\n"); - MdcPrntScrn("Attenuation Correction Method : %d\n" - ,ash.attenuation_type); - MdcPrntScrn("Number of Elements : %d (width)\n" - ,ash.dimension_1); - MdcPrntScrn("Number of Views : %d (height)\n" - ,ash.dimension_2); - MdcPrntScrn("Attenuation Scale Factor : %f\n",ash.scale_factor); - MdcPrntScrn("Ellipse X Offset : %f [cm]\n" - ,ash.x_origin); - MdcPrntScrn("Ellipse Y Offset : %f [cm]\n" - ,ash.y_origin); - MdcPrntScrn("Ellipse X Radius : %f [cm]\n" - ,ash.x_radius); - MdcPrntScrn("Ellipse Y Radius : %f [cm]\n" - ,ash.y_radius); - MdcPrntScrn("Ellipse Tilt Angle : %f [degrees]\n" - ,ash.tilt_angle); - MdcPrntScrn("Mu-Absorption Coefficient : %f [1/cm]\n" - ,ash.attenuation_coeff); - MdcPrntScrn("Sample Distance : %f [cm]\n" - ,ash.sample_distance); - } - - /* fill in IMG_DATA struct */ - id = &fi->image[img]; - id->width = (Uint32)ash.dimension_1; - id->height = (Uint32)ash.dimension_2; - - id->quant_units = 1; - id->quant_scale = 1; - id->calibr_units= 1; - id->calibr_fctr = 1; - - id->quant_scale = ash.scale_factor; - - data_type = ash.data_type; - switch( data_type ) { - case BYTE_TYPE: id->bits = 8; id->type = BIT8_U; break; - case M68K_I2 : - /* case SUN_I2 : */ - case VAX_I2 : id->bits =16; id->type = BIT16_S; break; - case M68K_I4 : - /* case SUN_I4 : */ - case VAX_I4 : id->bits =32; id->type = BIT32_S; break; - case IEEE_R4 : - /* case SUN_R4 : */ - case VAX_R4 : id->bits =32; id->type = FLT32; break; - } - - break; - - case MDC_ECAT6_NORM_FILE: - - error = mdc_mat_read_norm_subheader(fp, startblk-1, &nsh); - if (error) return("ECAT6 Bad read normalization subheader"); - if (MDC_INFO) { - MdcPrintLine('-',MDC_FULL_LENGTH); - MdcPrntScrn("NORMALIZATION SUBHEADER %05d: ",img+1); - MdcPrntScrn("Frame: %d Plane: %d Gate: %d Data: %d Bed: %d\n" - ,frame,plane,gate,data,bed); - MdcPrintLine('-',MDC_FULL_LENGTH); - MdcPrntScrn("Data Type : %d ",nsh.data_type); - if ((nsh.data_type > -1) && (nsh.data_type < 8)) - MdcPrntScrn("(= %s)\n",MdcEcatDataTypes[nsh.data_type]); - else - MdcPrntScrn("(= Unknown)\n"); - MdcPrntScrn("Number of Elements : %d (width)\n",nsh.dimension_1); - MdcPrntScrn("Number of Views : %d (height)\n",nsh.dimension_2); - MdcPrntScrn("Normalization Scale Factor : %f\n",nsh.scale_factor); - MdcPrntScrn("Normalization Start Hour : %d\n",nsh.norm_hour); - MdcPrntScrn("Normalization Start Minute : %d\n",nsh.norm_minute); - MdcPrntScrn("Normalization Start Second : %d\n",nsh.norm_second); - MdcPrntScrn("Normalization Start Day : %d\n",nsh.norm_day); - MdcPrntScrn("Normalization Start Month : %d\n",nsh.norm_month); - MdcPrntScrn("Normalization Start Year : %d\n",nsh.norm_year); - MdcPrntScrn("Field of View Source Width : %f [cm]\n" - ,nsh.fov_source_width); - MdcPrntScrn("Ecat Calibration Factor : %f\n" - ,nsh.ecat_calib_factor); - } - - /* fill in IMG_DATA struct */ - id = &fi->image[img]; - id->width = (Uint32)nsh.dimension_1; - id->height = (Uint32)nsh.dimension_2; - - id->quant_units = 1; - id->quant_scale = nsh.scale_factor; - id->calibr_units= mh.calibration_units; - id->calibr_fctr = nsh.ecat_calib_factor; - - data_type = nsh.data_type; - switch( data_type ) { - case BYTE_TYPE: id->bits = 8; id->type = BIT8_U; break; - case M68K_I2 : - /* case SUN_I2 : */ - case VAX_I2 : id->bits =16; id->type = BIT16_S; break; - case M68K_I4 : - /* case SUN_I4 : */ - case VAX_I4 : id->bits =32; id->type = BIT32_S; break; - case IEEE_R4 : - /* case SUN_R4 : */ - case VAX_R4 : id->bits =32; id->type = FLT32; break; - } - - break; - - } - - bytes = id->width*id->height*MdcType2Bytes(id->type); - bytes = MdcMatrixBlocks(bytes); - - id->buf = MdcGetImgBuffer(bytes); - if (id->buf == NULL) return("ECAT6 Bad malloc image buffer"); - - error = mdc_mat_read_matrix_data(fp,startblk,endblk,(Int16 *)id->buf); - - if (error) { - MdcPrntWarn("ECAT6 Bad read matrix data"); - err=MdcHandleTruncated(fi,img+1,MDC_YES); - if(err != NULL) return(err); - } - - if (fi->truncated) break; - - img+=1; - } - - /* check the images really found */ - if (num_matrices < fi->number) { - found = (Uint32)num_matrices; - }else if (img < fi->number) { - found = img; - }else { - found = fi->number; - } - if (found != fi->number) { - err=MdcHandleTruncated(fi,found,MDC_YES); - if (err != NULL) return(err); - } - - /* fill in other FILEINFO variables */ - id = &fi->image[0]; /* first image */ - fi->dim[1] = id->width; - fi->dim[2] = id->height; - fi->bits = id->bits; - fi->type = id->type; - fi->pixdim[0]=3; - fi->pixdim[1]=id->pixel_xsize; - fi->pixdim[2]=id->pixel_ysize; - fi->pixdim[3]=id->slice_width; - if (mh.file_type == MDC_ECAT6_IMAGE_FILE) { - MdcStringCopy(fi->filter_type,MdcEcatFilterTypes[abs(ish.filter_code)], - MDC_MAX_ECATFLTRTYPES_SIZE); - fi->reconstructed = MDC_YES; - if (ish.decay_corr_fctr > 1.0 ) fi->decay_corrected = MDC_YES; - - MdcStringCopy(fi->recon_method,ish.annotation,strlen(ish.annotation)); - if (strcmp(fi->recon_method,MDC_ECAT6_RECON_METHOD) == 0 ) { - strcpy(fi->recon_method,"Filtered Backprojection"); - } - }else{ - fi->reconstructed = MDC_NO; - strcpy(fi->recon_method,"None"); - } - - switch( data_type ) { - case BYTE_TYPE: MDC_FILE_ENDIAN = MDC_HOST_ENDIAN; break; -/* case SUN_I2 : */ - case M68K_I2 : MDC_FILE_ENDIAN = MDC_BIG_ENDIAN; break; - case VAX_I2 : MDC_FILE_ENDIAN = MDC_HOST_ENDIAN; break; -/* case SUN_I4 : */ - case M68K_I4 : MDC_FILE_ENDIAN = MDC_BIG_ENDIAN; break; - case VAX_I4 : MDC_FILE_ENDIAN = MDC_HOST_ENDIAN; break; -/* case SUN_R4 : */ - case IEEE_R4 : MDC_FILE_ENDIAN = MDC_BIG_ENDIAN; break; - case VAX_R4 : MDC_FILE_ENDIAN = MDC_HOST_ENDIAN; break; - } - - MdcCloseFile(fi->ifp); - - if (fi->truncated) return("ECAT6 Truncated image file"); - - return NULL; -} - -float MdcGetSliceLocation(FILEINFO *fi, Int32 img) -{ - int orient; - float locat=0.; - - orient = MdcGetIntSliceOrient((int)fi->pat_slice_orient); - - switch (orient) { - case MDC_TRANSAXIAL: /* z-coord */ - locat = fi->image[img].image_pos_pat[2]; - break; - case MDC_SAGITTAL : /* x-coord */ - locat = fi->image[img].image_pos_pat[0]; - break; - case MDC_CORONAL : /* y-coord */ - locat = fi->image[img].image_pos_pat[1]; - break; - } - - if (locat < 0.) locat = -locat; - - return(locat / 10.); /* cm */ - -} - -int MdcGetFilterCode(char *string) -{ - int i = 0; - - for (i=0; iimage[0]; - int i; - float init_bed_position=0.; - - /* memset(mh,0,MH_64_SIZE); */ - memset(mh,0,sizeof(Mdc_Main_header)); - - sprintf(mh->original_file_name,"%.19s",fi->ofname); - mh->sw_version = 6; - mh->system_type= 951; - mh->file_type = 2; - - mh->data_type = 2; /* ECAT 6 only reads VAX Int16 */ - - sprintf(mh->isotope_code,"%.8s",fi->isotope_code); - mh->isotope_halflife = fi->isotope_halflife; - sprintf(mh->radiopharmaceutical,"%.31s",fi->radiopharma); - mh->calibration_units = fi->image[0].calibr_units; - if (fi->pixdim[0] >= 3.) /* only valid for TRANSVERSE slices */ - mh->axial_fov = ((float)fi->dim[3] + 1.) * fi->pixdim[3] / 10.; - mh->scan_start_day = fi->study_date_day; - mh->scan_start_month = fi->study_date_month; - mh->scan_start_year = fi->study_date_year; - mh->scan_start_hour = fi->study_time_hour; - mh->scan_start_minute= fi->study_time_minute; - mh->scan_start_second= fi->study_time_second; - mh->plane_separation = fi->image[0].slice_spacing/10.; /* in cm */ - sprintf(mh->study_name,"%.11s",fi->study_id); - mh->gantry_tilt = fi->gantry_tilt; - sprintf(mh->patient_id,"%.15s",fi->patient_id); - if (fi->patient_height == 0.) { - mh->patient_height[0] = '\0'; - }else{ - sprintf(mh->patient_height,"%.2f",fi->patient_height); - } - if (fi->patient_weight == 0.) { - mh->patient_weight[0] = '\0'; - }else{ - sprintf(mh->patient_weight,"%.2f",fi->patient_weight); - } - sprintf(mh->patient_name,"%.31s",fi->patient_name); - mh->patient_sex = fi->patient_sex[0]; - sprintf(mh->operator_name,"%.31s",fi->operator_name); - sprintf(mh->study_description,"%.31s",fi->study_descr); - switch (fi->acquisition_type ) { - case MDC_ACQUISITION_STATIC : - mh->acquisition_type = MDC_ECAT6_ACQTYPE_STATIC_EMISSION; break; - case MDC_ACQUISITION_TOMO : - mh->acquisition_type = MDC_ECAT6_ACQTYPE_STATIC_EMISSION; break; - case MDC_ACQUISITION_DYNAMIC: - mh->acquisition_type = MDC_ECAT6_ACQTYPE_DYNAMIC_EMISSION; break; - case MDC_ACQUISITION_GSPECT : - mh->acquisition_type = MDC_ECAT6_ACQTYPE_GATED_EMISSION; break; - default : - mh->acquisition_type = MDC_ECAT6_ACQTYPE_UNKNOWN; - - } - sprintf(mh->facility_name,"%.19s",fi->institution); - sprintf(mh->user_process_code,"%.10s",MDC_PRGR); - - mh->num_planes = mh->num_frames = mh->num_gates = 1; - mh->num_bed_pos = 1; - - for ( i=3; i<=fi->dim[0]; i++) { - switch (i) { - case 3: mh->num_planes = fi->dim[i]; break; - case 4: mh->num_frames = fi->dim[i]; break; - case 5: mh->num_gates = fi->dim[i]; break; - case 6: mh->num_bed_pos = fi->dim[i]; break; - case 7: mh->num_bed_pos*= fi->dim[i]; break; - } - } - mh->num_bed_pos -= 1; /* zero-based */ - - /* bed positions */ - if ((fi->bednr > 0) && (fi->beddata != NULL)) { - /* use preserved bed offsets */ - - mh->init_bed_position = fi->beddata[0].hoffset / 10.; /* cm */ - mh->bed_elevation = fi->beddata[0].voffset / 10.; /* cm */ - - for (i=1; ibednr; i++) { - if ( i==16 ) { - MdcPrntWarn("ECAT6 Unsupported number of bed positions"); - break; - } - mh->bed_offset[i-1] = fi->beddata[i].hoffset - fi->beddata[0].hoffset; - mh->bed_offset[i-1] /= 10.; /* cm */ - } - }else{ - /* guess bad offsets, assume adjacent bed positions */ - - switch (MdcGetIntSliceOrient(fi->pat_slice_orient)) { - case MDC_TRANSAXIAL: - init_bed_position = dd0->image_pos_pat[2]; /* x */ - break; - case MDC_CORONAL : - init_bed_position = dd0->image_pos_pat[1]; /* y */ - break; - case MDC_SAGITTAL : - init_bed_position = dd0->image_pos_pat[0]; /* z */ - break; - } - if (init_bed_position < 0.) - init_bed_position *= -1.; - if (init_bed_position > dd0->slice_width) - init_bed_position -= dd0->slice_width; - - mh->init_bed_position = init_bed_position / 10.; /* cm */ - - for (i=1; idim[6]; i++) { - mh->bed_offset[i-1] = dd0->slice_width * (float)(fi->dim[3] * i / 10); - } - } -} - -void MdcFillImageSubHeader(FILEINFO *fi,Mdc_Image_subheader *ish - ,int type,Int32 img, Int32 matnum, Uint32 NEWSIZE) -{ - IMG_DATA *id = &fi->image[img]; - Uint32 fnr; - Int32 fstart=0, fduration=0; - - /* memset(ish,0,ISH_64_SIZE); */ - memset(ish,0,sizeof(Mdc_Image_subheader)); - - fnr = id->frame_number; - if ((fi->dynnr > 0) && (fnr > 0)) { - fstart = (Int32)fi->dyndata[fnr-1].time_frame_start; - fduration = (Int32)fi->dyndata[fnr-1].time_frame_duration; - }else{ - fstart = 0; fduration = 0; - } - - ish->data_type = 2; /* ECAT 6 only reads VAX Int16 */ - - ish->num_dimensions = 2; - if (fi->diff_size || NEWSIZE) { - ish->dimension_1 = fi->mwidth; - ish->dimension_2 = fi->mheight; - }else{ - ish->dimension_1 = id->width; - ish->dimension_2 = id->height; - } - ish->recon_scale = id->recon_scale; - - if (ish->data_type == 1 || ish->data_type == 2) { - if (id->rescaled) { - ish->image_min = (Int16) id->rescaled_min; - ish->image_max = (Int16) id->rescaled_max; - }else{ - ish->image_min = (Int16) id->min; - ish->image_max = (Int16) id->max; - } - }else{ /* data types too big for an Int16 */ - ish->image_min = 0; - ish->image_max = 0; - } - ish->pixel_size = ((id->pixel_xsize + id->pixel_ysize)/2.) / 10.; - ish->slice_width = id->slice_width / 10.; -#ifdef MDC_USE_SLICE_SPACING - if (fi->number > 1) ish->slice_width = id->slice_spacing / 10.; -#endif - ish->frame_duration = fduration; - ish->frame_start_time = fstart; - ish->slice_location = (Int16)MdcGetSliceLocation(fi,img); - ish->filter_code = -(MdcGetFilterCode(fi->filter_type)); - - ish->scan_matrix_num = matnum; - ish->norm_matrix_num = matnum; - ish->atten_cor_matrix_num = matnum; - - ish->quant_units = id->quant_units; - - if (id->rescaled) { - ish->quant_scale = id->rescaled_fctr; - ish->ecat_calibration_fctr = 1.; - }else{ - ish->quant_scale = id->quant_scale; - ish->ecat_calibration_fctr = id->calibr_fctr; - } - - if (strcmp(fi->recon_method,"Filtered Backprojection") == 0 ) { - sprintf(ish->annotation,"%.40s",MDC_ECAT6_RECON_METHOD); - }else{ - sprintf(ish->annotation,"%.40s",fi->recon_method); - } + return MDC_FRMT_NONE; } -static void MdcResetSizes(FILEINFO *fi) +char *MdcReadECAT6(FILEINFO *fi) { - fi->mwidth = saved_mwidth; - fi->mheight= saved_mheight; + return("ECAT Reading unsupported (unclear licensing)"); } - -const char *MdcWriteECAT6(FILEINFO *fi) -{ - IMG_DATA *id; - Mdc_Main_header mh; - Mdc_Image_subheader ish; - Uint8 *buf, *maxbuf; - Uint16 type, FREE; - Int32 matnum, data=0, bed, gate, frame, plane, img=0; - Uint32 size, NEWSIZE=0; - - if (MDC_FILE_STDOUT == MDC_YES) - return("ECAT6 Writing to stdout unsupported for this format"); - - MDC_WRITE_ENDIAN = MDC_LITTLE_ENDIAN; /* always (VAX) */ - - if (XMDC_GUI == MDC_NO) { - MdcDefaultName(fi,MDC_FRMT_ECAT6,fi->ofname,fi->ifname); - } - - if (MDC_PROGRESS) MdcProgress(MDC_PROGRESS_BEGIN,0.,"Writing ECAT6:"); - - if (MDC_VERBOSE) MdcPrntMesg("ECAT6 Writing <%s> ...",fi->ofname); - - /* check for colored files */ - if (fi->map == MDC_MAP_PRESENT) - return("ECAT6 Colored files unsupported"); - - if (MdcKeepFile(fi->ofname)) { - return("ECAT6 File exists!!"); - } - - if (MDC_FORCE_INT != MDC_NO) { - if (MDC_FORCE_INT != BIT16_S) { - MdcPrntWarn("ECAT6 Only Int16 pixels supported"); - } - } - - /* check some integrities */ - - /* check integrity of planes, frames, gates, beds */ - if (fi->dim[3] > MDC_ECAT6_MAX_PLANES) - return("ECAT6 number of planes too big (1024)"); - if (fi->dim[4] > MDC_ECAT6_MAX_FRAMES) - return("ECAT6 number of frames too big (512)"); - if (fi->dim[5] > MDC_ECAT6_MAX_GATES) - return("ECAT6 number of gates too big (64)"); - if ((fi->dim[6]*fi->dim[7]) > MDC_ECAT6_MAX_BEDS) - return("ECAT6 number of beds too big (16)"); - - -#if MDC_ECAT6_RESTRICT_DIMS - /* check dimensions (ECAT only 64, 128, 256) */ - /* we don't do downsaling */ - if (fi->mwidth > MDC_ECAT6_MAX_DIMS || fi->mheight > MDC_ECAT6_MAX_DIMS) - return("ECAT6 dimensions too big (256)"); -#endif - - /* get maximum dimension */ - if (fi->mwidth > fi->mheight) size = fi->mwidth; - else size = fi->mheight; - -#if MDC_ECAT6_RESTRICT_DIMS - /* allow only 64, 128, 256 */ - if (size <= 64) NEWSIZE=64; - else if (size <= 128) NEWSIZE=128; - else if (size <= 256) NEWSIZE=256; -#endif - - /* save the original dimensions anyway */ - saved_mwidth = fi->mwidth; - saved_mheight= fi->mheight; - - /* change to new dimensions */ - if (NEWSIZE) { - fi->mwidth = NEWSIZE; - fi->mheight= NEWSIZE; - } - - MdcFillMainHeader(fi,&mh); - - if ( (fi->ofp = mdc_mat_create(fi->ofname,&mh)) == NULL) { - MdcResetSizes(fi); - return("Couldn't create file"); - } - for (bed=0; bed <= mh.num_bed_pos; bed++) - for (gate=1; gate <= mh.num_gates; gate++) - for (frame=1; frame <= mh.num_frames; frame++) - for (plane=1; plane <= mh.num_planes; plane++) { - - if (MDC_PROGRESS) MdcProgress(MDC_PROGRESS_INCR,1./(float)fi->number,NULL); - - id = &fi->image[img]; - - if ((id->type != BIT16_S) || MDC_QUANTIFY || MDC_CALIBRATE) { - buf = MdcGetImgBIT16_S(fi, (Uint32)img); - FREE=MDC_YES; type=BIT16_S; - }else{ - buf = id->buf; - FREE=MDC_NO; type=id->type; - } - - matnum = mdc_mat_numcod(frame,plane,gate,data,bed); - MdcFillImageSubHeader(fi,&ish,type,img,matnum,NEWSIZE); - - if (fi->diff_size || NEWSIZE) { - size = fi->mwidth * fi->mheight * MdcType2Bytes(type); - - maxbuf = MdcGetResizedImage(fi, buf, type, (Uint32)img); - if (maxbuf == NULL) { - MdcResetSizes(fi); - return("ECAT6 Bad malloc maxbuf"); - } - - if (FREE) MdcFree(buf); - - FREE=MDC_YES; - - }else{ /* NEWSIZE is normally always set */ - size = id->width * id->height * MdcType2Bytes(type); - maxbuf = buf; - } - - matnum = mdc_mat_numcod(frame,plane,gate,data,bed); - if (mdc_mat_write_image(fi->ofp,matnum,&ish,(Uint16 *)maxbuf,(Int32)size)) - { - MdcResetSizes(fi); - return("ECAT6 Bad write image matrix"); - } - - img+=1; - - if (FREE) MdcFree(maxbuf); - } - - MdcCheckQuantitation(fi); - - MdcCloseFile(fi->ofp); - - MdcResetSizes(fi); - - return NULL; -} - -void MdcPrintEcatInfoDB(Mdc_Main_header *mh) +char *MdcWriteECAT6(FILEINFO *fi) { - char Unknown[8]="Unknown"; - - Uint32 i, patient_strlen, study_strlen; - - patient_strlen = strlen(mh->patient_name); - study_strlen = strlen(mh->study_name); - - /* remove # from strings, because it is used as field separator! */ - for (i=0; ipatient_name[i] == '#' ) { - mh->patient_name[i]='$'; - } - } - - /* print database info: study_name */ - if (study_strlen != 6) { - MdcPrntScrn("%s",Unknown); - }else{ - MdcPrntScrn("%s",mh->study_name); - } - MdcPrntScrn("# "); - - /* print database info: patient_name */ - if (patient_strlen == 0) { - MdcPrntScrn("%-35s",Unknown); - }else{ - MdcPrntScrn("%-35s",mh->patient_name); - } - - MdcPrntScrn("#"); - - /* print database info: scan date */ - MdcPrntScrn("%02d-",mh->scan_start_day); - switch (mh->scan_start_month) { - case 1: MdcPrntScrn("Jan"); break; - case 2: MdcPrntScrn("Feb"); break; - case 3: MdcPrntScrn("Mar"); break; - case 4: MdcPrntScrn("Apr"); break; - case 5: MdcPrntScrn("May"); break; - case 6: MdcPrntScrn("Jun"); break; - case 7: MdcPrntScrn("Jul"); break; - case 8: MdcPrntScrn("Aug"); break; - case 9: MdcPrntScrn("Sep"); break; - case 10: MdcPrntScrn("Oct"); break; - case 11: MdcPrntScrn("Nov"); break; - case 12: MdcPrntScrn("Dec"); break; - } - MdcPrntScrn("-%4d",mh->scan_start_year); - MdcPrntScrn("\n"); + return("ECAT Writing unsupported (unclear licensing)"); } --- a/source/m-ecat64.h +++ b/source/m-ecat64.h @@ -7,12 +7,14 @@ * * * project : (X)MedCon by Erik Nolf * * * + * Notes : DEBIAN - code removed due to unclear licensing * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* $Id: m-ecat64.h,v 1.21 2013/06/23 21:51:19 enlf Exp $ +/* - debian dummy file v0.1 - */ /* - Copyright (C) 1997-2013 by Erik Nolf + Copyright (C) 1997-2002 by Erik Nolf This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -37,65 +39,13 @@ #include "m-matrix.h" -/**************************************************************************** D E F I N E S -****************************************************************************/ - -#define MDC_ECAT6_MAX_PLANES 1024 -#define MDC_ECAT6_MAX_FRAMES 512 -#define MDC_ECAT6_MAX_GATES 64 -#define MDC_ECAT6_MAX_BEDS 16 - -#define MDC_ECAT6_MAX_DIMS 256 - -#define MDC_ECAT6_SYST_TYPE 951 - -#define MDC_ECAT6_SCAN_FILE 1 -#define MDC_ECAT6_IMAGE_FILE 2 -#define MDC_ECAT6_ATTN_FILE 3 -#define MDC_ECAT6_NORM_FILE 4 - -#define MDC_ECAT6_ACQTYPE_UNKNOWN 0 -#define MDC_ECAT6_ACQTYPE_BLANK 1 -#define MDC_ECAT6_ACQTYPE_TRANSMISSION 2 -#define MDC_ECAT6_ACQTYPE_STATIC_EMISSION 3 -#define MDC_ECAT6_ACQTYPE_DYNAMIC_EMISSION 4 -#define MDC_ECAT6_ACQTYPE_GATED_EMISSION 5 -#define MDC_ECAT6_ACQTYPE_TRANSMISSION_RECT 6 -#define MDC_ECAT6_ACQTYPE_EMISSION_RECT 7 -#define MDC_ECAT6_ACQTYPE_WHOLE_BODY_TRANSM 8 -#define MDC_ECAT6_ACQTYPE_WHOLE_BODY_STATIC 9 - -#define MDC_MAX_ECATDATATYPES 8 -#define MDC_MAX_ECATDATATYPES_SIZE 11 -#define MDC_MAX_ECATFILETYPES 6 -#define MDC_MAX_ECATFILETYPES_SIZE 14 -#define MDC_MAX_ECATACQTYPES 10 -#define MDC_MAX_ECATACQTYPES_SIZE 25 -#define MDC_MAX_ECATFLTRTYPES 8 -#define MDC_MAX_ECATFLTRTYPES_SIZE 8 -#define MDC_MAX_ECATQUANTTYPES 12 -#define MDC_MAX_ECATQUANTTYPES_SIZE 25 - -#define MDC_MAX_ECATSYSTEMTYPES 6 - -#define MDC_ECAT6_RECON_METHOD "ACS reconstruction with new AP" - -#define MDC_ECAT6_SORT_ANATOMICAL 1 -#define MDC_ECAT6_SORT_BYFRAME 2 - - /**************************************************************************** F U N C T I O N S ****************************************************************************/ int MdcCheckECAT6(FILEINFO *fi); -const char *MdcReadECAT6(FILEINFO *fi); -const char *MdcWriteECAT6(FILEINFO *fi); -float MdcGetSliceLocation(FILEINFO *fi, Int32 img); -int MdcGetFilterCode(char *string); -void MdcFillMainHeader(FILEINFO *fi, Mdc_Main_header *mh); -void MdcFillImageSubHeader(FILEINFO *fi, Mdc_Image_subheader *ish,int type,Int32 img,Int32 matnum,Uint32 NEWSIZE); -void MdcPrintEcatInfoDB(Mdc_Main_header *mh); +char *MdcReadECAT6(FILEINFO *fi); +char *MdcWriteECAT6(FILEINFO *fi); #endif --- a/source/m-ecat72.c +++ b/source/m-ecat72.c @@ -10,18 +10,17 @@ * Functions : MdcCheckECAT7() - Check for ECAT7 format * * MdcEcatPrintMainHdr() - Print content main header * * MdcEcatPrintImgSubHdr() - Print content image subheader * - * MdcEcatPrintAttnSubHdr() - Print content attenuation hdr * - * MdcEcatPrintScanSubHdr() - Print content scan header * - * MdcEcatPrintNormSubHdr() - Print content norm header * * MdcReadECAT7() - Read ECAT7 file * * MdcWriteECAT7() - Write ECAT7 file * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* $Id: m-ecat72.c,v 1.75 2013/06/23 21:51:19 enlf Exp $ +/* $Id: m-ecat72.c,v 1.14 2003/04/24 23:25:10 enlf Exp $ + */ +/* - debian dummy file v0.2 - by Roland Marcus Rutschmann */ /* - Copyright (C) 1997-2013 by Erik Nolf + Copyright (C) 1997-2003 by Erik Nolf This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -44,7 +43,6 @@ #include "m-depend.h" #include -#define __USE_POSIX 1 #include #ifdef HAVE_STDLIB_H #include @@ -60,1448 +58,25 @@ #include "medcon.h" -#if MDC_INCLUDE_TPC -#define MDC_TPC_SITE 0 /* 0/1 disable/enable TPC site items */ -#define __USE_ISOC99 1 -#include -#include "ecat7.h" -#endif - - /**************************************************************************** D E F I N E S ****************************************************************************/ -#define MDC_NUM_PLANES_FIX MDC_YES /* fix for wrong num_planes = 1 bug */ - -#define MDC_MAX_ECAT7FILETYPES 15 -#define MDC_MAX_ECAT7FILETYPES_SIZE 15 - -static char MdcEcat7FileTypes - [MDC_MAX_ECAT7FILETYPES][MDC_MAX_ECAT7FILETYPES_SIZE]= - {"Unknown","Sinogram","Image16","AttnCorr","Norm", - "PolarMap","Volume8","Volume16","Projection8", - "Projection16","Image8","3DSino16","3DSino8", - "3DNorm","3DSinoFlt"}; /**************************************************************************** F U N C T I O N S ****************************************************************************/ int MdcCheckECAT7(FILEINFO *fi) { - Mdc_Main_header7 mh; - - if (mdc_mat_read_main_header7(fi->ifp,&mh)) return MDC_BAD_READ; - - if (memcmp(mh.magic_number,MDC_ECAT7_SIG,7) ) return(MDC_FRMT_NONE); - - return MDC_FRMT_ECAT7; - + return MDC_FRMT_NONE; } -void MdcEcatPrintMainHdr(Mdc_Main_header7 *mh) +char *MdcReadECAT7(FILEINFO *fi) { - int i; - - MdcPrintLine('-',MDC_HALF_LENGTH); - MdcPrntScrn("ECAT7 Main Header (%d bytes)\n",MH_72_SIZE); - MdcPrintLine('-',MDC_HALF_LENGTH); - - MdcGetSafeString(mdcbufr,(char *)mh->magic_number,14,14); - MdcPrntScrn("magic_number : %s\n",mdcbufr); - MdcGetSafeString(mdcbufr,mh->original_file_name,32,32); - MdcPrntScrn("original_file_name : %s\n",mdcbufr); - MdcPrntScrn("sw_version : %hd\n",mh->sw_version); - MdcPrntScrn("system_type : %hd\n",mh->system_type); - MdcPrntScrn("file_type : %hd ",mh->file_type); - if ((mh->file_type > -1) && (mh->file_type < 15)) - MdcPrntScrn("(= %s)\n",MdcEcat7FileTypes[mh->file_type]); - else - MdcPrntScrn("(= Unknown)\n"); - MdcGetSafeString(mdcbufr,mh->serial_number,10,10); - MdcPrntScrn("serial_number : %s\n",mdcbufr); - MdcPrntScrn("scan_start_time : %s\n" - ,ctime((time_t *)&mh->scan_start_time)); - MdcGetSafeString(mdcbufr,mh->isotope_name,8,8); - MdcPrntScrn("isotope_name : %s\n",mdcbufr); - MdcPrntScrn("isotope_halflife : %f [sec]\n",mh->isotope_halflife); - MdcGetSafeString(mdcbufr,mh->radiopharmaceutical,32,32); - MdcPrntScrn("radiopharmaceutical : %s\n",mdcbufr); - MdcPrntScrn("gantry_tilt : %f [degrees]\n",mh->gantry_tilt); - MdcPrntScrn("gantry_rotation : %f [degrees]\n",mh->gantry_rotation); - MdcPrntScrn("bed_elevation : %f [cm]\n",mh->bed_elevation); - MdcPrntScrn("intrinsic_tilt : %f [degrees]\n",mh->intrinsic_tilt); - MdcPrntScrn("wobble_speed : %hd [rpm]\n",mh->wobble_speed); - MdcPrntScrn("tansm_source_type : %hd\n",mh->transm_source_type); - MdcPrntScrn("distance_scanned : %f [cm]\n",mh->distance_scanned); - MdcPrntScrn("transaxial_fov : %f [cm]\n",mh->transaxial_fov); - MdcPrntScrn("angular_compression : %hd\n",mh->angular_compression); - MdcPrntScrn("coin_samp_mode : %hd\n",mh->coin_samp_mode); - MdcPrntScrn("axial_samp_mode : %hd\n",mh->axial_samp_mode); - MdcPrntScrn("ecat_calibration_factor : %e\n",mh->ecat_calibration_factor); - MdcPrntScrn("calibration_units : %hd\n",mh->calibration_units); - MdcPrntScrn("calibration_units_label : %hd\n",mh->calibration_units_label); - MdcPrntScrn("compression_code : %hd\n",mh->compression_code); - MdcGetSafeString(mdcbufr,mh->study_type,14,14); - MdcPrntScrn("study_type : %s\n",mdcbufr); - MdcGetSafeString(mdcbufr,mh->patient_id,16,16); - MdcPrntScrn("patient_id : %s\n",mdcbufr); - MdcGetSafeString(mdcbufr,mh->patient_name,32,32); - MdcPrntScrn("patient_name : %s\n",mdcbufr); - MdcPrntScrn("patient_sex : "); - switch (mh->patient_sex[0]) { - case 0: MdcPrntScrn("M\n"); break; - case 1: MdcPrntScrn("F\n"); break; - default: MdcPrntScrn("U\n"); - } - MdcPrntScrn("patient_dexterity : %c\n",mh->patient_dexterity[0]); - MdcPrntScrn("patient_age : %f\n",mh->patient_age); - MdcPrntScrn("patient_height : %f\n",mh->patient_height); - MdcPrntScrn("patient_weight : %f\n",mh->patient_weight); - MdcPrntScrn("patient_birth_date : %s\n" - ,ctime((time_t *)&mh->patient_birth_date)); - MdcGetSafeString(mdcbufr,mh->physician_name,32,32); - MdcPrntScrn("physician_name : %s\n",mdcbufr); - MdcGetSafeString(mdcbufr,mh->operator_name,32,32); - MdcPrntScrn("operator_name : %s\n",mdcbufr); - MdcGetSafeString(mdcbufr,mh->study_description,32,32); - MdcPrntScrn("study_description : %s\n",mdcbufr); - MdcPrntScrn("acquisition_type : %hd\n",mh->acquisition_type); - MdcPrntScrn("patient_orientation : %hd\n",mh->patient_orientation); - MdcGetSafeString(mdcbufr,mh->facility_name,20,20); - MdcPrntScrn("facility_name : %s\n",mdcbufr); - MdcPrntScrn("num_planes : %hd\n",mh->num_planes); - MdcPrntScrn("num_frames : %hd\n",mh->num_frames); - MdcPrntScrn("num_gates : %hd\n",mh->num_gates); - MdcPrntScrn("num_bed_pos : %hd\n",mh->num_bed_pos); - MdcPrntScrn("init_bed_position : %f\n",mh->init_bed_position); - for (i=0; i<15; i++) - MdcPrntScrn("bed_position[%2d] : %f\n",i,mh->bed_position[i]); - MdcPrntScrn("plane_separation : %f [cm]\n",mh->plane_separation); - MdcPrntScrn("lwr_sctr_thres : %hd [Kev]\n",mh->lwr_sctr_thres); - MdcPrntScrn("lwr_true_thres : %hd [Kev]\n",mh->lwr_true_thres); - MdcPrntScrn("upr_true_thres : %hd [Kev]\n",mh->upr_true_thres); - MdcGetSafeString(mdcbufr,mh->user_process_code,10,10); - MdcPrntScrn("user_process_code : %s\n",mdcbufr); - MdcPrntScrn("acquisition_mode : %hd\n",mh->acquisition_mode); - MdcPrntScrn("bin_size : %f [cm]\n",mh->bin_size); - MdcPrntScrn("branching_fraction : %f\n",mh->branching_fraction); - MdcPrntScrn("dose_start_time : %s\n" - ,ctime((time_t *)&mh->dose_start_time)); - MdcPrntScrn("dosage : %e [mCi]\n",mh->dosage); - MdcPrntScrn("well_counter_corr_factor : %f\n",mh->well_counter_corr_factor); - MdcGetSafeString(mdcbufr,mh->data_units,32,32); - MdcPrntScrn("data_units : %s\n",mdcbufr); - MdcPrntScrn("septa_state : %hd\n",mh->septa_state); - for (i=0; i<6; i++) - MdcPrntScrn("fill_cti[%d] : %hd\n",i,mh->fill_cti[i]); - + return("ECAT7 Reading in debian unsupported (unclear licensing)"); } -void MdcEcatPrintImgSubHdr(Mdc_Image_subheader7 *ish, int nr) -{ - MdcPrintLine('-',MDC_HALF_LENGTH); - MdcPrntScrn("ECAT7 Image Sub Header %05d (%d bytes)\n",nr,ISH_72_SIZE); - MdcPrintLine('-',MDC_HALF_LENGTH); - - MdcPrntScrn("data_type : %hd\n",ish->data_type); - MdcPrntScrn("num_dimensions : %hd\n",ish->num_dimensions); - MdcPrntScrn("x_dimension : %hd\n",ish->x_dimension); - MdcPrntScrn("y_dimension : %hd\n",ish->y_dimension); - MdcPrntScrn("z_dimension : %hd\n",ish->z_dimension); - MdcPrntScrn("x_offset : %f [cm]\n",ish->x_offset); - MdcPrntScrn("y_offset : %f [cm]\n",ish->y_offset); - MdcPrntScrn("z_offset : %f [cm]\n",ish->z_offset); - MdcPrntScrn("recon_zoom : %f\n",ish->recon_zoom); - MdcPrntScrn("scale_factor : %e\n",ish->scale_factor); - MdcPrntScrn("image_min : %hd\n",ish->image_min); - MdcPrntScrn("image_max : %hd\n",ish->image_max); - MdcPrntScrn("x_pixel_size : %f [cm]\n",ish->x_pixel_size); - MdcPrntScrn("y_pixel_size : %f [cm]\n",ish->y_pixel_size); - MdcPrntScrn("z_pixel_size : %f [cm]\n",ish->z_pixel_size); - MdcPrntScrn("frame_duration : %d [ms]\n",ish->frame_duration); - MdcPrntScrn("frame_start_time : %d [ms]\n",ish->frame_start_time); - MdcPrntScrn("filter_code : %hd\n",ish->filter_code); - MdcPrntScrn("x_resolution : %g\n",ish->x_resolution); - MdcPrntScrn("y_resolution : %g\n",ish->y_resolution); - MdcPrntScrn("z_resolution : %g\n",ish->z_resolution); - MdcPrntScrn("num_r_elements : %g\n",ish->num_r_elements); - MdcPrntScrn("num_angles : %g\n",ish->num_angles); - MdcPrntScrn("z_rotation_angle ; %g\n",ish->z_rotation_angle); - MdcPrntScrn("decay_corr_fctr : %g\n",ish->decay_corr_fctr); - MdcPrntScrn("processing_code : %d\n",ish->processing_code); - MdcPrntScrn("gate_duration : %u\n",ish->gate_duration); - MdcPrntScrn("r_wave_offset : %d\n",ish->r_wave_offset); - MdcPrntScrn("num_accepted_beats : %d\n",ish->num_accepted_beats); - MdcPrntScrn("filter_cutoff_frequency : %g\n",ish->filter_cutoff_frequency); - MdcPrntScrn("filter_resolution : %g\n",ish->filter_resolution); - MdcPrntScrn("filter_ramp_slope : %g\n",ish->filter_ramp_slope); - MdcPrntScrn("filter_order : %hd\n",ish->filter_order); - MdcPrntScrn("filter_scatter_fraction : %g\n",ish->filter_scatter_fraction); - MdcPrntScrn("filter_scatter_slope : %g\n",ish->filter_scatter_slope); - MdcGetSafeString(mdcbufr,ish->annotation,40,40); - MdcPrntScrn("annotation : %s\n",mdcbufr); - MdcPrntScrn("mt_1_1 : %g\n",ish->mt_1_1); - MdcPrntScrn("mt_1_2 : %g\n",ish->mt_1_2); - MdcPrntScrn("mt_1_3 : %g\n",ish->mt_1_3); - MdcPrntScrn("mt_2_1 : %g\n",ish->mt_2_1); - MdcPrntScrn("mt_2_2 : %g\n",ish->mt_2_2); - MdcPrntScrn("mt_2_3 : %g\n",ish->mt_2_3); - MdcPrntScrn("mt_3_1 : %g\n",ish->mt_3_1); - MdcPrntScrn("mt_3_2 : %g\n",ish->mt_3_2); - MdcPrntScrn("mt_3_3 : %g\n",ish->mt_3_3); - MdcPrntScrn("rfilter_cutoff : %g\n",ish->rfilter_cutoff); - MdcPrntScrn("rfilter_resolution : %g\n",ish->rfilter_resolution); - MdcPrntScrn("rfilter_code : %hd\n",ish->rfilter_code); - MdcPrntScrn("rfilter_order : %hd\n",ish->rfilter_order); - MdcPrntScrn("zfilter_cutoff : %g\n",ish->zfilter_cutoff); - MdcPrntScrn("zfilter_resolution : %g\n",ish->zfilter_resolution); - MdcPrntScrn("zfilter_code : %hd\n",ish->zfilter_code); - MdcPrntScrn("zfilter_order : %hd\n",ish->zfilter_order); - MdcPrntScrn("mt_1_4 : %g\n",ish->mt_1_4); - MdcPrntScrn("mt_2_4 : %g\n",ish->mt_2_4); - MdcPrntScrn("mt_3_4 : %g\n",ish->mt_3_4); - MdcPrntScrn("scatter_type : %hd\n",ish->scatter_type); - MdcPrntScrn("recon_type : %hd\n",ish->recon_type); - MdcPrntScrn("recon_views : %hd\n",ish->recon_views); - MdcPrntScrn("fill_cti[87] : \n"); - MdcPrntScrn("fill_user[48] : \n"); - -} - -void MdcEcatPrintAttnSubHdr(Mdc_Attn_subheader7 *ash, int nr) -{ - int i; - - MdcPrintLine('-',MDC_HALF_LENGTH); - MdcPrntScrn("ECAT7 Attenuation Sub Header %05d (%d bytes)\n",nr,ASH_72_SIZE); - MdcPrintLine('-',MDC_HALF_LENGTH); - - MdcPrntScrn("data_type : %hd\n",ash->data_type); - MdcPrntScrn("num_dimensions : %hd\n",ash->num_dimensions); - MdcPrntScrn("attenuation_type : %hd\n",ash->attenuation_type); - MdcPrntScrn("num_r_elements : %hd\n",ash->num_r_elements); - MdcPrntScrn("num_angles : %hd\n",ash->num_angles); - MdcPrntScrn("num_z_elements : %hd\n",ash->num_z_elements); - MdcPrntScrn("ring_difference : %hd\n",ash->ring_difference); - MdcPrntScrn("x_resolution : %g [cm]\n",ash->x_resolution); - MdcPrntScrn("y_resolution : %g [cm]\n",ash->y_resolution); - MdcPrntScrn("z_resolution : %g [cm]\n",ash->z_resolution); - MdcPrntScrn("w_resolution : %g\n",ash->w_resolution); - MdcPrntScrn("scale_factor : %e\n",ash->scale_factor); - MdcPrntScrn("x_offset : %g [cm]\n",ash->x_offset); - MdcPrntScrn("y_offset : %g [cm]\n",ash->y_offset); - MdcPrntScrn("x_radius : %g [cm]\n",ash->x_radius); - MdcPrntScrn("y_radius : %g [cm]\n",ash->y_radius); - MdcPrntScrn("tilt_angle : %g [degrees]\n",ash->tilt_angle); - MdcPrntScrn("attenuation_coeff : %g [1/cm]\n",ash->attenuation_coeff); - MdcPrntScrn("attenuation_min : %g\n",ash->attenuation_min); - MdcPrntScrn("attenuation_max : %g\n",ash->attenuation_max); - MdcPrntScrn("skull_thickness : %g [cm]\n",ash->skull_thickness); - MdcPrntScrn("num_xtra_atten_coeff : %hd\n",ash->num_xtra_atten_coeff); - for (i=0; i<8; i++) - MdcPrntScrn("xtra_atten_coeff[%d] : %g\n",i,ash->xtra_atten_coeff[i]); - MdcPrntScrn("edge_finding_threshold : %g\n",ash->edge_finding_threshold); - MdcPrntScrn("storage_order : %hd\n",ash->storage_order); - MdcPrntScrn("span : %hd\n",ash->span); - for (i=0; i<64; i++) - MdcPrntScrn("z_elements[%2d] : %hd\n",i,ash->z_elements[i]); - MdcPrntScrn("fill_unused[86] : \n"); - MdcPrntScrn("fill_user[50] : \n"); - -} - -void MdcEcatPrintScanSubHdr(Mdc_Scan_subheader7 *ssh) -{ - MdcPrntScrn("data_type : %hd\n",ssh->data_type); - MdcPrntScrn("num_dimensions : %hd\n",ssh->num_dimensions); - MdcPrntScrn("num_r_elements : %hd\n",ssh->num_r_elements); - MdcPrntScrn("num_angles : %hd\n",ssh->num_angles); - MdcPrntScrn("corrections_applied : %hd\n",ssh->corrections_applied); - MdcPrntScrn("num_z_elements : %hd\n",ssh->num_z_elements); - MdcPrntScrn("ring_difference : %hd\n",ssh->ring_difference); - MdcPrntScrn("x_resolution : %g [cm]\n",ssh->x_resolution); - MdcPrntScrn("y_resolution : %g [cm]\n",ssh->y_resolution); - MdcPrntScrn("z_resolution : %g [cm]\n",ssh->z_resolution); - MdcPrntScrn("w_resolution : %g\n",ssh->w_resolution); - MdcPrntScrn("fill[6] : \n"); - MdcPrntScrn("gate_duration : %u [ms]\n",ssh->gate_duration); - MdcPrntScrn("r_wave_offset : %d [ms]\n",ssh->r_wave_offset); - MdcPrntScrn("num_accepted_beats : %d\n",ssh->num_accepted_beats); - MdcPrntScrn("scale_factor : %e\n",ssh->scale_factor); - MdcPrntScrn("scan_min : %hd\n",ssh->scan_min); - MdcPrntScrn("scan_max : %hd\n",ssh->scan_max); - MdcPrntScrn("prompts : %d\n",ssh->prompts); - MdcPrntScrn("delayed : %d\n",ssh->delayed); - MdcPrntScrn("multiples : %d\n",ssh->multiples); - MdcPrntScrn("net_trues : %d\n",ssh->net_trues); - MdcPrntScrn("cor_singles[16] : \n"); - MdcPrntScrn("uncor_singles[16] : \n"); - MdcPrntScrn("tot_avg_cor : %g\n",ssh->tot_avg_cor); - MdcPrntScrn("tot_avg_uncor : %g\n",ssh->tot_avg_uncor); - MdcPrntScrn("total_coin_rate : %d\n",ssh->total_coin_rate); - MdcPrntScrn("frame_start_time : %u\n",ssh->frame_start_time); - MdcPrntScrn("frame_duration : %u\n",ssh->frame_duration); - MdcPrntScrn("deadtime_correction_factor: %g\n" - ,ssh->deadtime_correction_factor); - MdcPrntScrn("phy_planes[8] : \n"); - MdcPrntScrn("cti_fill[90] : \n"); - MdcPrntScrn("user_fill[50] : \n"); - -} - - -void MdcEcatPrintNormSubHdr(Mdc_Norm_subheader7 *nsh) -{ - MdcPrntScrn("data_type : %hd\n",nsh->data_type); - MdcPrntScrn("num_dimensions : %hd\n",nsh->num_dimensions); - MdcPrntScrn("num_r_elements : %hd\n",nsh->num_r_elements); - MdcPrntScrn("num_angles : %hd\n",nsh->num_angles); - MdcPrntScrn("num_z_elements : %hd\n",nsh->num_z_elements); - MdcPrntScrn("ring_difference : %hd\n",nsh->ring_difference); - MdcPrntScrn("scale_factor : %e\n",nsh->scale_factor); - MdcPrntScrn("norm_min : %g\n",nsh->norm_min); - MdcPrntScrn("norm_max : %g\n",nsh->norm_max); - MdcPrntScrn("fov_source_width : %g\n",nsh->fov_source_width); - MdcPrntScrn("norm_quality_factor : %g\n",nsh->norm_quality_factor); - MdcPrntScrn("norm_quality_factor_code : %hd\n",nsh->norm_quality_factor_code); - MdcPrntScrn("storage_order : %hd\n",nsh->storage_order); - MdcPrntScrn("span : %hd\n",nsh->span); - MdcPrntScrn("z_elements[64] : \n"); - MdcPrntScrn("cti_fill[123] : \n"); - MdcPrntScrn("user_fill[50] : \n"); - -} - -const char *MdcReadECAT7(FILEINFO *fi) -{ - FILE *fp = fi->ifp; - int i, error/*, UNSUPPORTED*/; - const char *err; - char *str; - struct tm time, *ptime; - Mdc_Main_header7 mh; - Mdc_Image_subheader7 ish; - Mdc_Attn_subheader7 ash; -/* - Mdc_Scan_subheader7 ssh; - Mdc_Norm_subheader7 nsh; -*/ - struct Mdc_MatDir entry, matrix_list[MDC_ECAT7_MAX_MATRICES]; - struct Mdc_Matval matval; - Uint32 number, slice, img=0, vol=0, bytes; - Uint32 group=0, group_slice, skip_bytes=0, row, rbytes; - int bed,gate,frame,plane,nb,ng,nf,np,nd; - int matnum, startblk, endblk, num_matrices; - IMG_DATA *id; - DYNAMIC_DATA *dd=NULL; - Int16 bits, type; - Uint8 *mbufr, *pmbufr, *pbuf; - float slice_position; - - if (MDC_PROGRESS) MdcProgress(MDC_PROGRESS_BEGIN,0.,"Reading ECAT7:"); - - if (MDC_VERBOSE) MdcPrntMesg("ECAT7 Reading <%s> ...",fi->ifname); - - /* put some defaults we use */ - fi->endian=MDC_FILE_ENDIAN=MDC_BIG_ENDIAN; - fi->modality = M_PT; - - error = mdc_mat_read_main_header7(fp, &mh); - if (error) return("ECAT7 Bad read main header"); - - if (MDC_INFO || MDC_INFO_DB) MdcEcatPrintMainHdr(&mh); - - if (MDC_INFO_DB) return(NULL); /* just needed db info */ - - /* check for supported file types * - switch (mh.file_type) { - case MDC_ECAT7_FILE_TYPE_IMAGE16 : - case MDC_ECAT7_FILE_TYPE_VOLUME8 : - case MDC_ECAT7_FILE_TYPE_VOLUME16: - case MDC_ECAT7_FILE_TYPE_IMAGE8 : - UNSUPPORTED = MDC_NO; - break; - default: - UNSUPPORTED = MDC_YES; - }*/ - /* if (UNSUPPORTED == MDC_YES) return("ECAT7 Unsupported file type"); */ - - if (mh.num_frames <= 0 ) mh.num_frames = 1; - if (mh.num_gates <= 0 ) mh.num_gates = 1; - if (mh.num_bed_pos < 0 ) mh.num_bed_pos = 0; - - /* fill in global FILEINFO data */ - fi->dim[0]= 6; - fi->dim[3]= mh.num_planes; - fi->dim[4]= mh.num_frames; - fi->dim[5]= mh.num_gates; - fi->dim[6]= mh.num_bed_pos + 1; /* must be 1-based */ - - /* check for unsupported bed overlap */ - if (fi->dim[6] > 1) { - float axial_width, bed_offset=mh.bed_position[0]; - - if (bed_offset < 0) bed_offset = -bed_offset; - - axial_width = mh.plane_separation * (float)fi->dim[3]; - if ((axial_width - bed_offset) >= 1.0) { - MdcPrntWarn("ECAT7 Bed overlaps unsupported"); - } - } - - for (i=3, number=1; i<=6; i++) number*=fi->dim[i]; - - if (number == 0) return("ECAT7 No valid images specified"); - - /* fill in orientation information */ - switch (mh.patient_orientation) { - case MDC_ECAT7_FEETFIRST_PRONE: - fi->pat_slice_orient = MDC_PRONE_FEETFIRST_TRANSAXIAL; break; - case MDC_ECAT7_HEADFIRST_PRONE: - fi->pat_slice_orient = MDC_PRONE_HEADFIRST_TRANSAXIAL; break; - case MDC_ECAT7_FEETFIRST_SUPINE: - fi->pat_slice_orient = MDC_SUPINE_FEETFIRST_TRANSAXIAL; break; - case MDC_ECAT7_HEADFIRST_SUPINE: - fi->pat_slice_orient = MDC_SUPINE_HEADFIRST_TRANSAXIAL; break; - case MDC_ECAT7_FEETFIRST_RIGHT: - fi->pat_slice_orient = MDC_DECUBITUS_RIGHT_FEETFIRST_TRANSAXIAL; break; - case MDC_ECAT7_HEADFIRST_RIGHT: - fi->pat_slice_orient = MDC_DECUBITUS_RIGHT_HEADFIRST_TRANSAXIAL; break; - case MDC_ECAT7_FEETFIRST_LEFT: - fi->pat_slice_orient = MDC_DECUBITUS_LEFT_FEETFIRST_TRANSAXIAL; break; - case MDC_ECAT7_HEADFIRST_LEFT: - fi->pat_slice_orient = MDC_DECUBITUS_LEFT_HEADFIRST_TRANSAXIAL; break; - default: - fi->pat_slice_orient = MDC_SUPINE_HEADFIRST_TRANSAXIAL; - MdcPrntWarn("ECAT7 unknown patient orientation"); - } - - str = MdcGetStrPatPos(fi->pat_slice_orient); - MdcStringCopy(fi->pat_pos,str,strlen(str)); - - str = MdcGetStrPatOrient(fi->pat_slice_orient); - MdcStringCopy(fi->pat_orient,str,strlen(str)); - - /* fill in patient study related information */ - switch (mh.patient_sex[0]) { - case 0: fi->patient_sex[0] = 'M'; break; - case 1: fi->patient_sex[0] = 'F'; break; - default: fi->patient_sex[0] = 'U'; - } - fi->patient_sex[1]='\0'; - MdcStringCopy(fi->patient_name,mh.patient_name,32); - MdcStringCopy(fi->patient_id,mh.patient_id,16); - fi->patient_height = mh.patient_height; - fi->patient_weight = mh.patient_weight; - - ptime = &time; -#ifdef HAVE_LOCALTIME_R - localtime_r((time_t *)&(mh.patient_birth_date), ptime); -#else - ptime = localtime((time_t *)&(mh.patient_birth_date)); -#endif - if (ptime == NULL) { - MdcPrntWarn("ECAT7: Couldn't resolve patient birth date"); - strcpy(fi->patient_dob,"00000000"); - }else{ - sprintf(fi->patient_dob,"%.4d%.2d%.2d",ptime->tm_year + 1900 - ,ptime->tm_mon + 1 - ,ptime->tm_mday); - } - - ptime = &time; -#ifdef HAVE_LOCALTIME_R - localtime_r((time_t *)&(mh.scan_start_time), ptime); -#else - ptime = localtime((time_t *)&(mh.scan_start_time)); -#endif - if (ptime == NULL) { - MdcPrntWarn("ECAT7: Couldn't resolve scan start time"); - fi->study_date_day = 0; - fi->study_date_month = 1; - fi->study_date_year = 1900; - fi->study_time_hour = 0; - fi->study_time_minute= 0; - fi->study_time_second= 0; - }else{ - fi->study_date_day = ptime->tm_mday; - fi->study_date_month = ptime->tm_mon + 1; - fi->study_date_year = ptime->tm_year + 1900; - fi->study_time_hour = ptime->tm_hour; - fi->study_time_minute= ptime->tm_min; - fi->study_time_second= ptime->tm_sec; - } - - switch (mh.acquisition_type) { - case MDC_ECAT7_SCAN_TRANSMISSION: - case MDC_ECAT7_SCAN_STATIC_EMISSION: - fi->acquisition_type = MDC_ACQUISITION_TOMO; - break; - case MDC_ECAT7_SCAN_DYNAMIC_EMISSION: - fi->acquisition_type = MDC_ACQUISITION_DYNAMIC; - break; - case MDC_ECAT7_SCAN_GATED_EMISSION: - fi->acquisition_type = MDC_ACQUISITION_GSPECT; - break; - case MDC_ECAT7_SCAN_BLANK: - case MDC_ECAT7_SCAN_TRANS_RECTILINEAR: - case MDC_ECAT7_SCAN_EMISSION_RECTILINEAR: - default: - fi->acquisition_type = MDC_ACQUISITION_UNKNOWN; - break; - } - - sprintf(mdcbufr,"ECAT%hd",mh.system_type); - MdcStringCopy(fi->manufacturer,mdcbufr,strlen(mdcbufr)); - MdcStringCopy(fi->operator_name,mh.operator_name,32); - MdcStringCopy(fi->study_descr,mh.study_description,32); - MdcStringCopy(fi->study_id,mh.study_type,12); - MdcStringCopy(fi->institution,mh.facility_name,20); - MdcStringCopy(fi->radiopharma,mh.radiopharmaceutical,32); - MdcStringCopy(fi->isotope_code,mh.isotope_name,8); - - fi->isotope_halflife = mh.isotope_halflife; - fi->injected_dose = MdcmCi2MBq(mh.dosage); - fi->gantry_tilt = mh.gantry_tilt; - - if (MDC_ECHO_ALIAS == MDC_YES) { - MdcEchoAliasName(fi); return(NULL); - } - - if (!MdcGetStructID(fi,number)) - return("ECAT7 Bad malloc IMG_DATA structs"); - - /* always malloc dyndata structs */ - if (!MdcGetStructDD(fi,(Uint32)fi->dim[4]*fi->dim[5]*fi->dim[6])) - return("ECAT7 Couldn't malloc DYNAMIC_DATA structs"); - - /* ECAT7: matrices for each volume */ - num_matrices = mdc_mat_list7(fp, matrix_list, MDC_ECAT7_MAX_MATRICES); - if (num_matrices == 0) - return("ECAT7 No matrices found"); - if ((Uint32)num_matrices > (fi->number / fi->dim[3])) - return("ECAT7 Too many matrices found"); - - if (MDC_MY_DEBUG) { - int t; - - MdcDebugPrint("%d.%d.%d.%d",fi->dim[3] - ,fi->dim[4] - ,fi->dim[5] - ,fi->dim[6]); - - for (t=0; tdim[6]; bed++) - for (gate=1; gate<=fi->dim[5]; gate++) - for (frame=1; frame<=fi->dim[4]; frame++, vol++) - for (plane=1; plane<=fi->dim[3]; ) { - - if (vol == num_matrices) break; - - if (fi->dynnr > 0) dd = &fi->dyndata[(fi->dim[4]*bed) + (frame-1)]; - - mdc_mat_numdoc(matrix_list[vol].matnum,&matval); - nf = matval.frame; np = matval.plane; ng = matval.gate; - nb = matval.bed; nd = matval.data; - matnum = mdc_mat_numcod(nf,np,ng,nd,nb); - MdcDebugPrint("matnum = %d",matnum); - if (!mdc_mat_lookup7(fp, matnum, &entry)) continue; - startblk = entry.strtblk + 1; - endblk = entry.endblk - entry.strtblk; - - MdcDebugPrint("entry.endblk = %d",entry.endblk); - MdcDebugPrint("entry.strtblk= %d",entry.strtblk); - MdcDebugPrint("startblk = %d",startblk); - MdcDebugPrint("endblk = %d",endblk); - - switch (mh.file_type) { - - case MDC_ECAT7_FILE_TYPE_IMAGE8 : - case MDC_ECAT7_FILE_TYPE_IMAGE16 : - case MDC_ECAT7_FILE_TYPE_VOLUME8 : - case MDC_ECAT7_FILE_TYPE_VOLUME16: - - error = mdc_mat_read_image_subheader7(fp, startblk-1, &ish); - if (error) return("ECAT7 Bad read image subheader"); - - if (MDC_INFO) MdcEcatPrintImgSubHdr(&ish, (int)(vol + 1)); - - fi->dim[1] = ish.x_dimension; - fi->dim[2] = ish.y_dimension; - -#if MDC_NUM_PLANES_FIX - if ((mh.num_planes != ish.z_dimension) && (vol == 0)) { - - MdcPrntWarn("ECAT7 Fix wrong num_planes value"); - - mh.num_planes = ish.z_dimension; - fi->dim[3] = ish.z_dimension; - - for (i=3, number=1; i<=6; i++) number*=fi->dim[i]; - if (!MdcGetStructID(fi,number)) - return("ECAT7 Bad realloc IMG_DATA structs"); - - } -#endif - - switch (ish.data_type) { - case BYTE_TYPE: - bits = 8; type = BIT8_U; break; - case VAX_I2: - case SUN_I2: - bits = 16; type = BIT16_S; break; - case VAX_I4: - case SUN_I4: - bits = 32; type = BIT32_S; break; - case VAX_R4: - case IEEE_R4: - bits = 32; type = FLT32; break; - default: - return("ECAT7: Unsupported data type"); - } - - /* fill in DYNAMIC_DATA structs */ - if ((dd != NULL) && (plane == 1)) { - /* just one subheader */ - dd->nr_of_slices = fi->dim[3]; - dd->time_frame_start = (float)ish.frame_start_time; - dd->time_frame_duration = (float)ish.frame_duration; - } - - /* bytes entire volume (matrix blocks) */ - bytes = fi->dim[1] * fi->dim[2] * fi->dim[3] * MdcType2Bytes(type); - MdcDebugPrint("volume: %d bytes",bytes); - bytes = MdcMatrixBlocks(bytes); - - MdcDebugPrint("matrix: %d bytes",bytes); - - mbufr = malloc(bytes); - if (mbufr == NULL) - return("ECAT7 Bad malloc image matrix data buffer"); - - error = mdc_mat_read_mat_data(fp,startblk,endblk,mbufr,ish.data_type); - - if (error) { - MdcPrntWarn("ECAT7 Bad read image matrix data"); - err=MdcHandleTruncated(fi,img+1,MDC_YES); - if(err != NULL) { MdcFree(mbufr); return(err); } - } - - if (fi->truncated) break; - - /* bytes each image */ - bytes = fi->dim[1] * fi->dim[2] * MdcType2Bytes(type); - - for (slice=0; slice < fi->dim[3]; slice++, img++, plane++) { - - if (MDC_PROGRESS) - MdcProgress(MDC_PROGRESS_INCR,1./(float)fi->number,NULL); - - /* fill in IMG_DATA struct */ - id = &fi->image[img]; - id->width = fi->dim[1]; - id->height= fi->dim[2]; - id->bits = bits; - id->type = type; - - id->quant_units = 1; - id->quant_scale = ish.scale_factor; - id->calibr_units = mh.calibration_units; - id->calibr_fctr = mh.ecat_calibration_factor; - - id->pixel_xsize = ish.x_pixel_size * 10.0; /* mm */ - id->pixel_ysize = ish.y_pixel_size * 10.0; /* mm */ - id->slice_width = ish.z_pixel_size * 10.0; /* mm */ - id->slice_spacing = id->slice_width; - - /* slice position with bed offset (mm) */ - if (bed == 0) { - slice_position = mh.init_bed_position; - }else{ - slice_position = mh.init_bed_position + mh.bed_position[bed-1]; - } - slice_position *= 10.; /* mm */ - - MdcFillImgPos(fi,img,slice,slice_position); - - MdcFillImgOrient(fi,img); - - id->buf = MdcGetImgBuffer(bytes); - if (id->buf == NULL) { - MdcFree(mbufr); - return("ECAT7 Bad malloc image buffer"); - } - - memcpy(id->buf, mbufr + (bytes*slice), bytes); - - } - - MdcFree(mbufr); - - break; - - case MDC_ECAT7_FILE_TYPE_ATTNCORR: - - error = mdc_mat_read_attn_subheader7(fp, startblk-1, &ash); - if (error) return("ECAT7 Bad read attenuation subheader"); - - if (MDC_INFO) MdcEcatPrintAttnSubHdr(&ash, (int)(vol + 1)); - - fi->dim[1] = ash.num_r_elements; - fi->dim[2] = ash.num_angles; - - /* MARK: just retrieve group0 */ - /* fi->dim[3] = ash.num_z_elements; */ - - /* MARK: or retrieve all */ - fi->dim[3] = 0; - for (i=0; ash.z_elements[i]; i++) fi->dim[3] += ash.z_elements[i]; - - - for (i=3, number=1; i<=6; i++) number*=fi->dim[i]; - if (!MdcGetStructID(fi,number)) - return("ECAT7 Bad realloc IMG_DATA structs"); - - switch (ash.data_type) { - case BYTE_TYPE: - bits = 8; type = BIT8_U; break; - case VAX_I2: - case SUN_I2: - bits = 16; type = BIT16_S; break; - case VAX_I4: - case SUN_I4: - bits = 32; type = BIT32_S; break; - case VAX_R4: - case IEEE_R4: - bits = 32; type = FLT32; break; - default: - return("ECAT7: Unsupported data type"); - } - - /* bytes entire volume (matrix blocks) */ - bytes = fi->dim[1] * fi->dim[2] * fi->dim[3] * MdcType2Bytes(type); - MdcDebugPrint("volume: %d bytes",bytes); - bytes = MdcMatrixBlocks(bytes); - - - MdcDebugPrint("matrix: %d bytes",bytes); - - mbufr = malloc(bytes); - if (mbufr == NULL) - return("ECAT7 Bad malloc attenuation matrix data buffer"); - - endblk = startblk + (bytes / MdcMatBLKSIZE) - 1; - - error = mdc_mat_read_mat_data(fp,startblk,endblk,mbufr,ash.data_type); - - if (error) { - MdcPrntWarn("ECAT7 Bad read attenuation matrix data"); - err=MdcHandleTruncated(fi,img+1,MDC_YES); - if(err != NULL) { MdcFree(mbufr); return(err); } - } - - if (fi->truncated) break; - - /* bytes each image */ - bytes = fi->dim[1] * fi->dim[2] * MdcType2Bytes(type); - - - group_slice=0; - for (slice=0; slice < fi->dim[3]; slice++, img++, plane++) { - - if (MDC_PROGRESS) - MdcProgress(MDC_PROGRESS_INCR,1./(float)fi->number,NULL); - - /* fill in IMG_DATA struct */ - id = &fi->image[img]; - id->width = fi->dim[1]; - - id->height= fi->dim[2]; - id->bits = bits; - id->type = type; - - id->quant_units = 1; - id->quant_scale = ash.scale_factor; - id->calibr_units = mh.calibration_units; - id->calibr_fctr = mh.ecat_calibration_factor; - - id->pixel_xsize = ash.x_resolution * 10.0; /* mm */ - id->pixel_ysize = ash.y_resolution * 10.0; /* mm */ - id->slice_width = ash.z_resolution * 10.0; /* mm */ - id->slice_spacing = id->slice_width; - - /* slice position with bed offset (mm) */ - if (bed == 0) { - slice_position = mh.init_bed_position; - }else{ - slice_position = mh.init_bed_position + mh.bed_position[bed-1]; - } - slice_position *= 10.; /* mm */ - - MdcFillImgPos(fi,img,slice,slice_position); - - MdcFillImgOrient(fi,img); - - id->buf = MdcGetImgBuffer(bytes); - if (id->buf == NULL) { - MdcFree(mbufr); - return("ECAT7 Bad malloc image buffer"); - } - - /* copy date */ - if (ash.storage_order == 0) { - /* view mode: for the first group of z_elements we have */ - /* all 1st rows, all 2nd rows, etc. Then follows */ - /* same storage for next group of z_elements, */ - /* at least we think */ - /* MARK: still not proper for all groups, actually only 1st ok*/ - rbytes = fi->dim[1] * MdcType2Bytes(type); - if (group_slice == ash.z_elements[group] ) { - skip_bytes += ash.z_elements[group] * bytes; - group += 1; - group_slice = 0; - } - pmbufr = mbufr + skip_bytes + group_slice * rbytes; /* MARK */ - - /* MARK printf("DEBUG: skip_bytes(%u) + group_slice(%u) * rbytes (%u) = %u\n",skip_bytes,group_slice,rbytes,skip_bytes+group_slice*rbytes); */ - - for (row=0; row < fi->dim[2]; row++) { - pbuf = id->buf+(rbytes * row); - memcpy(pbuf, pmbufr, rbytes); - pmbufr += ash.z_elements[group] * rbytes; - } - }else{ - /* sinogram mode: fine, just copy */ - memcpy(id->buf, mbufr + (bytes*slice), bytes); - } - - group_slice++; - - } - - MdcFree(mbufr); - - break; - - default: - - return("ECAT7 Unsupported file type"); - - } - - } - - /* set remaing FILEINFO data */ - id = &fi->image[0]; - fi->bits = id->bits; - fi->type = id->type; - fi->pixdim[0] = 3; - fi->pixdim[1] = id->pixel_xsize; - fi->pixdim[2] = id->pixel_ysize; - fi->pixdim[3] = id->slice_width; - - switch (mh.file_type) { - case MDC_ECAT7_FILE_TYPE_IMAGE8 : - case MDC_ECAT7_FILE_TYPE_IMAGE16 : - case MDC_ECAT7_FILE_TYPE_VOLUME8 : - case MDC_ECAT7_FILE_TYPE_VOLUME16: - fi->reconstructed = MDC_YES; - if (ish.decay_corr_fctr > 1.0) fi->decay_corrected = MDC_YES; - break; - default: - fi->reconstructed = MDC_NO; - } - - MdcCloseFile(fi->ifp); - - if (fi->truncated) return("ECAT7 Truncated image file"); - - return(NULL); - -} - -#if MDC_INCLUDE_TPC -/*! - * Converts FILEINFO structure and MDC mainheader to TPC ecat7 mainheader - * - * @param mh pointer to MDC mainheader - * @param h pointer to TPC imageheader - * @param image_i image index number [0..fi->number-1] - * @param frame_i frame index number [0..fi->dim[4]-1] - */ -int MdcConvertToTPCEcat7image(FILEINFO* fi, - ECAT7_imageheader* h, int image_i, int frame_i) -{ - int i = 0; - - /* short int <- ECAT7_SUNI2 (must be for matrix writing) */ - h->data_type = ECAT7_SUNI2; - h->num_dimensions = fi->dim[0]; - switch (fi->pat_slice_orient) { -#if MDC_TPC_SITE - case MDC_SAGITTAL: - /* short int <- Int16 */ - h->x_dimension = fi->dim[3]; - h->y_dimension = fi->dim[2]; - h->z_dimension = fi->dim[1]; - /* float <- ??? */ - h->x_offset = 0; - h->y_offset = 0; - h->z_offset = 0; - h->x_pixel_size = fi->pixdim[3]/10; - h->y_pixel_size = fi->pixdim[2]/10; - h->z_pixel_size = fi->pixdim[1]/10; - /* float <- ??? */ - h->x_resolution = 0.0f; - h->y_resolution = 0.0f; - h->z_resolution = 0.0f; - break; - case MDC_CORONAL: - /* short int <- Int16 */ - h->x_dimension = fi->dim[1]; - h->y_dimension = fi->dim[3]; - h->z_dimension = fi->dim[2]; - /* float <- ??? */ - h->x_offset = 0; - h->y_offset = 0; - h->z_offset = 0; - h->x_pixel_size = fi->pixdim[1]/10; - h->y_pixel_size = fi->pixdim[3]/10; - h->z_pixel_size = fi->pixdim[2]/10; - /* float <- ??? */ - h->x_resolution = 0.0f; - h->y_resolution = 0.0f; - h->z_resolution = 0.0f; - break; -#endif - default: - /* short int <- Int16 */ - h->x_dimension = fi->dim[1]; - h->y_dimension = fi->dim[2]; - h->z_dimension = fi->dim[3]; - /* float <- ??? */ - h->x_offset = 0; - h->y_offset = 0; - h->z_offset = 0; - h->x_pixel_size = fi->pixdim[1]/10; - h->y_pixel_size = fi->pixdim[2]/10; - h->z_pixel_size = fi->pixdim[3]/10; - /* float <- ??? */ - h->x_resolution = 0.0f; - h->y_resolution = 0.0f; - h->z_resolution = 0.0f; - break; - } - - if (fi->image) { -/* eNlf: MARK - leave out for now, currently no slice_location in IMG_DATA - switch(fi->pat_slice_orient) { -#if MDC_TPC_SITE - case MDC_SAGITTAL: - if(fi->dim[3] > 1 && fabs(fi->image[fi->number-1].slice_location - fi->image[0].slice_location) != 0) - h->x_pixel_size = fabs(fi->image[fi->number-1].slice_location - fi->image[0].slice_location)/((fi->dim[3]-1)*10.0f); - else - h->x_pixel_size = fi->image[0].slice_width/10; - break; - case MDC_CORONAL: - if(fi->dim[3] > 1 && fabs(fi->image[fi->number-1].slice_location - fi->image[0].slice_location) != 0) - h->y_pixel_size = fabs(fi->image[fi->number-1].slice_location - fi->image[0].slice_location)/((fi->dim[3]-1)*10.0f); - else - h->y_pixel_size = fi->image[0].slice_width/10; - break; -#endif - default: - if(fi->dim[3] > 1 && fabs(fi->image[fi->number-1].slice_location - fi->image[0].slice_location) != 0) - h->z_pixel_size = fabs(fi->image[fi->number-1].slice_location - fi->image[0].slice_location)/((fi->dim[3]-1)*10.0f); - else - h->z_pixel_size = fi->image[0].slice_width/10; - } -*/ - h->recon_zoom = fi->image[image_i].recon_scale; - - if (fi->image[image_i].rescaled) { - h->scale_factor = fi->image[image_i].rescaled_fctr; - }else{ - h->scale_factor = 1.; - } - - /* short int <- double */ - h->image_min = fi->image[image_i].min; - h->image_max = fi->image[image_i].max; - } - - if (fi->dyndata && frame_i < fi->dynnr) { - /* int <- float (ms) */ - h->frame_duration = fi->dyndata[frame_i].time_frame_duration; - /* int <- float (ms) */ - h->frame_start_time = fi->dyndata[frame_i].time_frame_start; - } - /* short int <- ??? */ - h->filter_code = 0; - /* float <- ??? */ - h->num_r_elements = 0; - /* float <- ??? */ - h->num_angles = 0.0f; - /* float <- ??? */ - h->z_rotation_angle = 0.0f; - /* float <- ??? */ - h->decay_corr_fctr = 0.0f; - /* int <- ??? */ - h->processing_code = 0; - if (fi->gdata) { - /* int <- float (ms) */ - h->gate_duration = fi->gdata->image_duration; - /* int <- float (ms) */ - h->r_wave_offset = fi->gdata->window_low; - h->num_accepted_beats = fi->gdata->cycles_acquired; - } - /* float <- ??? */ - h->filter_cutoff_frequency = 0.0f; - /* float <- ??? */ - h->filter_resolution = 0.0f; - /* float <- ??? */ - h->filter_ramp_slope = 0.0f; - /* short int <- ??? */ - h->filter_order = 0; - /* float <- ??? */ - h->filter_scatter_fraction = 0.0f; - /* float <- ??? */ - h->filter_scatter_slope = 0.0f; -/* char annotation[40]; */ - /* float <- ??? */ - h->mt_1_1 = 0.0f; - /* float <- ??? */ - h->mt_1_2 = 0.0f; - /* float <- ??? */ - h->mt_1_3 = 0.0f; - /* float <- ??? */ - h->mt_2_1 = 0.0f; - /* float <- ??? */ - h->mt_2_2 = 0.0f; - /* float <- ??? */ - h->mt_2_3 = 0.0f; - /* float <- ??? */ - h->mt_3_1 = 0.0f; - /* float <- ??? */ - h->mt_3_2 = 0.0f; - /* float <- ??? */ - h->mt_2_3 = 0.0f; - /* float <- ??? */ - h->rfilter_cutoff = 0.0f; - /* float <- ??? */ - h->rfilter_resolution = 0.0f; - /* short int <- ??? */ - h->rfilter_code = 0.0f; - /* short int <- ??? */ - h->rfilter_order = 0.0f; - /* float <- ??? */ - h->zfilter_cutoff = 0.0f; - /* float <- ??? */ - h->zfilter_resolution = 0.0f; - /* short int <- ??? */ - h->zfilter_code = 0; - /* short int <- ??? */ - h->zfilter_order = 0; - /* float <- ??? */ - h->mt_1_4 = 0.0f; - /* float <- ??? */ - h->mt_2_4 = 0.0f; - /* float <- ??? */ - h->mt_3_4 = 0.0f; - /* short int <- ??? */ - h->scatter_type = 0; - /* short int <- ??? */ - h->recon_type = 0; - /* short int <- ??? */ - h->recon_views = 0; - /* short int <- ??? */ - for(i = 0; i < 87; i++) h->fill_cti[i] = 0; - /* short int <- ??? */ - for(i = 0; i < 49; i++) h->fill_user[i] = 0; - - return 0; -} - -/*! - * Converts FILEINFO structure and MDC mainheader to TPC ecat7 mainheader - * - * @param fi file structure - * @param mh pointer to MDC mainheader - * @param h pointer to TPC mainheader - */ -int MdcConvertToTPCEcat7(FILEINFO* fi, - Mdc_Main_header* mh, ECAT7_mainheader* h) -{ - struct tm timeinfo; - int i = 0; - char number[5]; - - /* use default ecat7 magic number */ - strncpy(h->magic_number, ECAT7V_MAGICNR,14); - strncpy(h->original_file_name,mh->original_file_name,20); - h->sw_version = 72; - /* short int <- Int16 */ - h->system_type = mh->system_type; - /* short int <- ECAT7_VOLUME16 */ - h->file_type = ECAT7_VOLUME16; - strncpy(h->serial_number,"unknown",10); - /* int <- Int16 Int16 Int16 Int16 */ - memset((void *)&timeinfo,0,sizeof(timeinfo)); - timeinfo.tm_year = mh->scan_start_year-1900; - timeinfo.tm_mon = mh->scan_start_month-1; - timeinfo.tm_mday = mh->scan_start_day; - timeinfo.tm_hour = mh->scan_start_hour; - timeinfo.tm_min = mh->scan_start_minute; - timeinfo.tm_sec = mh->scan_start_second; - timeinfo.tm_isdst= -1; - h->scan_start_time = (unsigned int)mktime(&timeinfo); - strncpy(h->isotope_name,fi->isotope_code,(8isotope_halflife = mh->isotope_halflife; - strncpy(h->radiopharmaceutical, - fi->radiopharma,(32gantry_tilt = mh->gantry_tilt; - h->gantry_rotation = mh->gantry_rotation; - h->bed_elevation = mh->bed_elevation; - /* float <- ??? */ - h->intrinsic_tilt = 0.0f; - /* short int <- Int16 */ - h->wobble_speed = mh->wobble_speed; - /* short int <- Int16 */ - h->transm_source_type = mh->transm_source_type; - /* float <- ??? */ - h->distance_scanned = 0.0f; - h->transaxial_fov = mh->transaxial_fov; - /* short int <- Int16 */ - h->angular_compression = mh->compression_code; - /* short int <- Int16 */ - h->coin_samp_mode = mh->coin_samp_mode; - /* short int <- Int16 */ - h->axial_samp_mode = mh->axial_samp_mode; - h->ecat_calibration_factor = 1.; /* eNlf: global, prefer scale per plane*/ - /* short int <- Int16 */ - h->calibration_units = mh->calibration_units; - /* short int <- ??? */ - h->calibration_units_label = 0; - /* short int <- Int16 */ - h->compression_code = mh->compression_code; - strncpy(h->study_type,mh->study_name,12); - strncpy(h->patient_id,mh->patient_id,16); - strncpy(h->patient_name,mh->patient_name,32); - switch (fi->patient_sex[0]) { - case 'M': h->patient_sex = 0; break; - case 'F': h->patient_sex = 1; break; - default : h->patient_sex = 3; - } - h->patient_dexterity = mh->patient_dexterity; - sscanf(mh->patient_age,"%f",&h->patient_age); - h->patient_height = fi->patient_height; - h->patient_weight = fi->patient_weight; - - /* patient_dob: YYYYMMDD -> tm_year, tm_mon, tm_day -> unsigned int*/ - memset((void *)&timeinfo,0,sizeof(timeinfo)); - /* YYYY */ - memcpy(number,&fi->patient_dob[0],4); number[4]='\0'; - timeinfo.tm_year = atoi(number) - 1900; - /* MM */ - memcpy(number,&fi->patient_dob[4],2); number[2]='\0'; - timeinfo.tm_mon = atoi(number) - 1; - /* DD */ - memcpy(number,&fi->patient_dob[6],2); number[2]='\0'; - timeinfo.tm_mday = atoi(number); - h->patient_birth_date = (unsigned int)mktime(&timeinfo); - - strncpy(h->physician_name,mh->physician_name,32); - strncpy(h->operator_name,mh->operator_name,32); - strncpy(h->study_description,mh->study_description,32); - /* short int <- Int16 */ - h->acquisition_type = mh->acquisition_type; - /* short int <- char[MDC_MAXSTR] */ - h->patient_orientation = 0; - if(strncmp(fi->pat_pos,"FFP",3) == 0) h->patient_orientation = 0; - else if(strncmp(fi->pat_pos,"HFP",3) == 0) h->patient_orientation = 1; - else if(strncmp(fi->pat_pos,"FFS",3) == 0) h->patient_orientation = 2; - else if(strncmp(fi->pat_pos,"HFS",3) == 0) h->patient_orientation = 3; - else if(strncmp(fi->pat_pos,"FFDR",4) == 0) h->patient_orientation = 4; - else if(strncmp(fi->pat_pos,"HFDR",4) == 0) h->patient_orientation = 5; - else if(strncmp(fi->pat_pos,"FFDL",4) == 0) h->patient_orientation = 6; - else if(strncmp(fi->pat_pos,"HFDL",4) == 0) h->patient_orientation = 7; - else MdcPrntWarn("Unrecognized patient position: %s\n",fi->pat_pos); -#if MDC_TPC_SITE - strncpy(h->facility_name,mh->original_file_name,20); -#else - strncpy(h->facility_name,fi->institution,20); -#endif - /* short int <- Int16 */ - switch (fi->pat_slice_orient) { -#if MDC_TPC_SITE - case MDC_SAGITTAL: h->num_planes = fi->dim[1]; break; - case MDC_CORONAL: h->num_planes = fi->dim[2]; break; -#endif - default: h->num_planes = fi->dim[3]; break; - } - /* short int <- Int16 */ - h->num_frames = fi->dim[4]; - /* short int <- Int16 */ - h->num_gates = fi->dim[5]; - /* short int (zero-based value) <- Int16 (one-based value) */ - h->num_bed_pos = (fi->dim[6]>=1 ? fi->dim[6]-1 : 0); - h->init_bed_position = mh->init_bed_position; - for (i = 0; i < 15; i++) h->bed_position[i] = mh->bed_offset[i]; - h->plane_separation = mh->plane_separation; - /* short int <- Int16 */ - h->lwr_sctr_thres = mh->lwr_sctr_thres; - /* short int <- Int16 */ - h->lwr_true_thres = mh->lwr_true_thres; - /* short int <- Int16 */ - h->upr_true_thres = mh->upr_true_thres; - strncpy(h->user_process_code,mh->original_file_name,10); - /* short int <- Int16 */ - h->acquisition_mode = mh->acquisition_mode; - /* float <- ?? */ - h->bin_size = 0.0f; - /* float <- ?? */ - h->branching_fraction = 0.0f; - /* int <- Int16 Int16 Int16 Int16 */ - timeinfo.tm_year = fi->study_date_year-1900; - timeinfo.tm_mon = fi->study_date_month-1; - timeinfo.tm_mday = fi->study_date_day; - timeinfo.tm_hour = fi->dose_time_hour; - timeinfo.tm_min = fi->dose_time_minute; - timeinfo.tm_sec = fi->dose_time_second; - h->dose_start_time = (unsigned int)mktime(&timeinfo); - h->dosage = MdcMBq2mCi(fi->injected_dose); - /* float <- ?? */ - h->well_counter_corr_factor = 0.0f; - /* char[32] <- char[MDC_MAXSTR] */ - strncpy(h->data_units,"unknown",32); -/* eNlf: MARK - doesn't belong in modality XA - if (fi->mod) { - if ( strcmp(fi->mod->xa_info.Photo_Interp,"BQML") == 0 ) - strncpy(h->data_units,"kBq/ml",32); - } -*/ - /* int <- ??? */ - h->septa_state = 0; - /* int[6] <- ??? */ - for(i = 0; i < 6; i++) h->fill_cti[i] = 0; - - return 0; -} - -/*! - * Modified to execute TPC ecat7 writing - * - * @param fi file structure - * @return Error message, or NULL if successfull - */ -const char *MdcWriteECAT7(FILEINFO *fi) -{ - int ret = 0; - int bytes = 0; - ECAT7_mainheader h; - ECAT7_imageheader ih; - float* TPC_frame = 0; - float* TPC_frame_start = 0; - int frame_size = 0; -/* int plane_dir = 0;*/ - Uint32 uwidth, uheight; - IMG_DATA *id; - Mdc_Main_header mh; - Uint8 *buf, *maxbuf; - Int16 type; - Int32 matnum, bed, gate, frame, plane, img=0; -#if MDC_TPC_SITE - Int32 column, row; - float flt32=0; -#else - Uint32 size; -#endif - - if (MDC_FILE_STDOUT == MDC_YES) - return("ECAT7 Writing to stdout unsupported for this format"); - - MDC_WRITE_ENDIAN = MDC_LITTLE_ENDIAN; /* always (VAX) */ - - if (XMDC_GUI == MDC_NO) { - MdcDefaultName(fi,MDC_FRMT_ECAT7,fi->ofname,fi->ifname); - } - if (MDC_PROGRESS) MdcProgress(MDC_PROGRESS_BEGIN,0.,"Writing ECAT7:"); - if (MDC_VERBOSE) MdcPrntMesg("ECAT7 Writing <%s> ...",fi->ofname); - - /* check for colored files */ - if (fi->map == MDC_MAP_PRESENT) - return("ECAT7 Colored files unsupported"); - - if (MdcKeepFile(fi->ofname)) { - return("ECAT7 File exists!!"); - } - - if (MDC_FORCE_INT != MDC_NO) { - if (MDC_FORCE_INT != BIT16_S) { - MdcPrntWarn("ECAT7 Only Int16 pixels supported"); - } - } - - /* check some integrities */ - - /* check integrity of planes, frames, gates, beds */ - if (fi->dim[3] > MDC_ECAT7_MAX_PLANES) - return("ECAT7 number of planes too big (1024)"); - if (fi->dim[4] > MDC_ECAT7_MAX_FRAMES) - return("ECAT7 number of frames too big (512)"); - if (fi->dim[5] > MDC_ECAT7_MAX_GATES) - return("ECAT7 number of gates too big (32)"); - if ((fi->dim[6]*fi->dim[7]) > MDC_ECAT7_MAX_BEDS) - return("ECAT7 number of beds too big (32)"); - - /* use TPC library to open file */ - MdcFillMainHeader(fi,&mh); - MdcConvertToTPCEcat7(fi,&mh,&h); - fi->ofp=ecat7Create(fi->ofname, &h); - if (fi->ofp == NULL) { - return("ECAT7 Failed to open file for writing"); - } - - /* write all planes */ - frame_size = mh.num_planes*fi->mwidth*fi->mheight; - TPC_frame_start = (float*)malloc(frame_size*sizeof(float)); - if (TPC_frame_start == NULL) { - MdcCloseFile(fi->ofp); - return("ECAT7 Failed to allocate frame buffer"); - } - - if ( ! ( fi->pat_slice_orient == MDC_TRANSAXIAL || - fi->pat_slice_orient == MDC_CORONAL || - fi->pat_slice_orient == MDC_SAGITTAL )) { - MdcPrntWarn("ECAT7 Couldn't resolve slice orientation, using transaxial\n"); - } - - /* head feet direction L\P,L\FP,P\F,L\F,P\FR,R\F - plane_dir = MDC_HEADFIRST; - if (strcmp(fi->pat_orient,"L\\P") == 0) plane_dir = MDC_FEETFIRST; - else if (strcmp(fi->pat_orient,"R\\P") == 0) plane_dir = MDC_FEETFIRST; - else if (strcmp(fi->pat_orient,"L\\FP") == 0) plane_dir = MDC_HEADFIRST; - else if (strcmp(fi->pat_orient,"P\\F") == 0) plane_dir = MDC_HEADFIRST; - else if (strcmp(fi->pat_orient,"L\\F") == 0) plane_dir = MDC_HEADFIRST; - else if (strcmp(fi->pat_orient,"P\\FR") == 0) plane_dir = MDC_HEADFIRST; - else if (strcmp(fi->pat_orient,"R\\F") == 0) plane_dir = MDC_HEADFIRST; - else { - MdcPrntWarn("ECAT7 Unrecognized patient orientation: %s\n",fi->pat_orient); - }*/ - - for (bed=0; bed <= mh.num_bed_pos; bed++) - for (gate=1; gate <= mh.num_gates; gate++) - for (frame=1; frame <= h.num_frames; frame++) { - - TPC_frame = TPC_frame_start; - -#if MDC_TPC_SITE - for (plane = 0; plane < fi->dim[3]; plane++) { -#else - for (plane = 0; plane < fi->dim[3]; plane++, img++) { -#endif - if (MDC_PROGRESS) - MdcProgress(MDC_PROGRESS_INCR,1./(float)fi->number,NULL); - if (img < 0) { - img = fi->number-1; - MdcPrntWarn("ECAT7 underflow %d %d %d %d\n", - mh.num_bed_pos,mh.num_gates,h.num_frames,fi->dim[3]); - } - if (img >= fi->number) { - img = fi->number-1; - MdcPrntWarn("ECAT7 overflow %d %d %d %d\n", - mh.num_bed_pos,mh.num_gates,h.num_frames,fi->dim[3]); - } - -#if MDC_TPC_SITE - img = (h.num_frames - frame)*fi->dim[3]+plane; - id = &fi->image[img]; -#else - id = &fi->image[img]; -#endif - - /* TPC requires float buffer */ - buf = MdcGetImgFLT32(fi, (Uint32)img); - if (buf == NULL) { - MdcFree(TPC_frame_start); - return("ECAT7 Bad malloc float buf"); - } - type= FLT32; - - if (fi->diff_size) { - uwidth = fi->mwidth; uheight = fi->mheight; - maxbuf = MdcGetResizedImage(fi, buf, type, (Uint32)img); - if (maxbuf == NULL) { - MdcFree(buf); - MdcFree(TPC_frame_start); - return("ECAT7 Bad malloc maxbuf"); - } - MdcFree(buf); - }else{ - uwidth = id->width; uheight = id->height; - maxbuf = buf; - } - - bytes = MdcType2Bytes(type); - -#if MDC_TPC_SITE - /* copy plane to row-column-plane orientation as scaled float data */ - for (column=0; column < uwidth; column++) - for (row=0; row < uheight*bytes; row+=bytes) { - flt32 = *((float*)&maxbuf[column*uheight*bytes+row]); - *(TPC_frame + ((plane)*uheight*uwidth - + column*uheight - + (row/bytes))) = flt32; - } -#else - /* copy plane at once */ - size = uwidth * uheight; - - TPC_frame = TPC_frame_start + (size*plane); - memcpy(TPC_frame,maxbuf,size*bytes); -#endif - - MdcFree(maxbuf); - - } - - TPC_frame = TPC_frame_start; - matnum = mdc_mat_numcod(frame,1,1,0,0); - MdcConvertToTPCEcat7image(fi,&ih,img-1,frame-1); - ret = ecat7WriteImageMatrix(fi->ofp, matnum, &ih, TPC_frame); - if (ret) { - MdcFree(maxbuf); - MdcFree(TPC_frame); - MdcPrntWarn("ECAT7: Matrix write error code=%d\n",ret); - return("ECAT7 Bad write image matrix"); - } - - } - - MdcFree(TPC_frame); - - MdcCloseFile(fi->ofp); - - MdcCheckQuantitation(fi); - - return(NULL); -} - -#else - -const char *MdcWriteECAT7(FILEINFO *fi) +char *MdcWriteECAT7(FILEINFO *fi) { return("ECAT7 Writing not yet supported"); } - -#endif --- a/source/m-ecat72.h +++ b/source/m-ecat72.h @@ -8,11 +8,13 @@ * project : (X)MedCon by Erik Nolf * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* $Id: m-ecat72.h,v 1.19 2013/06/23 21:51:19 enlf Exp $ +/* $Id: m-ecat72.h,v 1.5 2003/03/30 22:58:52 enlf Exp $ + */ +/* - debian dummy file v0.1 - by Roland Marcus Rutschmann */ /* - Copyright (C) 1997-2013 by Erik Nolf + Copyright (C) 1997-2003 by Erik Nolf This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -32,70 +34,19 @@ #define __M_ECAT72_H__ /**************************************************************************** - D E F I N E S + D E F I N E S ****************************************************************************/ -#define MDC_ECAT7_SIG "MATRIX7" - -#define MDC_ECAT7_MAX_MATRICES 5000 - -#define MDC_ECAT7_MAX_PLANES 1024 -#define MDC_ECAT7_MAX_FRAMES 512 -#define MDC_ECAT7_MAX_GATES 32 -#define MDC_ECAT7_MAX_BEDS 32 - -#define MDC_ECAT7_FILE_TYPE_UNKNOWN 0 -#define MDC_ECAT7_FILE_TYPE_SINOGRAM 1 -#define MDC_ECAT7_FILE_TYPE_IMAGE16 2 -#define MDC_ECAT7_FILE_TYPE_ATTNCORR 3 -#define MDC_ECAT7_FILE_TYPE_NORM 4 -#define MDC_ECAT7_FILE_TYPE_POLARMAP 5 -#define MDC_ECAT7_FILE_TYPE_VOLUME8 6 -#define MDC_ECAT7_FILE_TYPE_VOLUME16 7 -#define MDC_ECAT7_FILE_TYPE_PROJECTION8 8 -#define MDC_ECAT7_FILE_TYPE_PROJECTION16 9 -#define MDC_ECAT7_FILE_TYPE_IMAGE8 10 -#define MDC_ECAT7_FILE_TYPE_3DSINO16 11 -#define MDC_ECAT7_FILE_TYPE_3DSINO8 12 -#define MDC_ECAT7_FILE_TYPE_3DNORM 13 -#define MDC_ECAT7_FILE_TYPE_3DSINOFLT 14 - -#define MDC_ECAT7_SOURCE_TYPE_NONE 1 -#define MDC_ECAT7_SOURCE_TYPE_RRING 2 -#define MDC_ECAT7_SOURCE_TYPE_RING 3 -#define MDC_ECAT7_SOURCE_TYPE_ROD 4 -#define MDC_ECAT7_SOURCE_TYPE_RROD 5 - -#define MDC_ECAT7_FEETFIRST_PRONE 0 -#define MDC_ECAT7_HEADFIRST_PRONE 1 -#define MDC_ECAT7_FEETFIRST_SUPINE 2 -#define MDC_ECAT7_HEADFIRST_SUPINE 3 -#define MDC_ECAT7_FEETFIRST_RIGHT 4 -#define MDC_ECAT7_HEADFIRST_RIGHT 5 -#define MDC_ECAT7_FEETFIRST_LEFT 6 -#define MDC_ECAT7_HEADFIRST_LEFT 7 - -#define MDC_ECAT7_SCAN_UNKNOWN 0 -#define MDC_ECAT7_SCAN_BLANK 1 -#define MDC_ECAT7_SCAN_TRANSMISSION 2 -#define MDC_ECAT7_SCAN_STATIC_EMISSION 3 -#define MDC_ECAT7_SCAN_DYNAMIC_EMISSION 4 -#define MDC_ECAT7_SCAN_GATED_EMISSION 5 -#define MDC_ECAT7_SCAN_TRANS_RECTILINEAR 6 -#define MDC_ECAT7_SCAN_EMISSION_RECTILINEAR 7 +/* All deleted in dummy +*/ /**************************************************************************** F U N C T I O N S ****************************************************************************/ int MdcCheckECAT7(FILEINFO *fi); -void MdcEcatPrintMainHdr(Mdc_Main_header7 *mh); -void MdcEcatPrintImgSubHdr(Mdc_Image_subheader7 *ish, int nr); -void MdcEcatPrintAttnSubHdr(Mdc_Attn_subheader7 *ash, int nr); -void MdcEcatPrintScanSubHdr(Mdc_Scan_subheader7 *ssh); -void MdcEcatPrintNormSubHdr(Mdc_Norm_subheader7 *nsh); -const char *MdcReadECAT7(FILEINFO *fi); -const char *MdcWriteECAT7(FILEINFO *fi); +char *MdcReadECAT7(FILEINFO *fi); +char *MdcWriteECAT7(FILEINFO *fi); #endif --- a/source/m-matrix.c +++ b/source/m-matrix.c @@ -7,1909 +7,9 @@ * * * project : (X)MedCon by Erik Nolf * * * - * Notes : Source code addapted from CTI PET Systems, Inc. * - * Original code 2.6 10/19/93 Copyright 1989-1993 * - * * - * Changed code for swapping & the use of our data types * - * with machine independency as target * - * * - * Put "mdc" prefix on functions and structs to prevent * - * naming conflicts with other tools based on CTI code * - * * - * Added functions for ECAT 7 reading support * - * * - * Original CTI Authors listed: * - * E. Phearson * - * L. Davis * - * Yaorong * + * Notes : DEBIAN - code removed due to licensing issues * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* $Id: m-matrix.c,v 1.35 2013/06/23 21:51:19 enlf Exp $ +/* - debian dummy file v0.1 - */ -/* - Copyright (C) 1997-2013 by Erik Nolf - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any later - version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General - Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 59 Place - Suite 330, Boston, MA 02111-1307, USA. */ - -/**************************************************************************** - H E A D E R S -****************************************************************************/ - -#include "m-depend.h" - -#include -#ifdef HAVE_STDLIB_H -#include -#endif -#ifdef HAVE_STRING_H -#include -#endif -#ifdef HAVE_STRINGS_H -#ifndef _WIN32 -#include -#endif -#endif - -#include "medcon.h" - -/*************************************************************************** - D E F I N E S -***************************************************************************/ - -struct ExpMatDir { - int matnum; - int strtblk; - int endblk; - int matstat; - float anatloc; -}; - -/**************************************************************************** - F U N C T I O N S -****************************************************************************/ - - - /*********************************************************/ - FILE *mdc_mat_open( fname, fmode) - char *fname, *fmode; -{ - FILE *fptr; - - fptr = fopen(fname, fmode); - return (fptr); - -} - /*********************************************************/ - void mdc_mat_close( fptr) - FILE *fptr; -{ - MdcCloseFile( fptr); -} - /*********************************************************/ - Int32 mdc_mat_rblk( fptr, blkno, bufr, nblks) - FILE *fptr; - Int32 blkno, nblks; - Uint8 *bufr; -{ - int r; - fseek( fptr, (blkno-1)*MdcMatBLKSIZE, 0); - r = fread( bufr, 1, (unsigned)(nblks*MdcMatBLKSIZE), fptr); - if (r != (nblks*MdcMatBLKSIZE)) return(-1); - - return (0); -} - /*********************************************************/ - - Int32 mdc_mat_list( fptr, mlist, lmax) - FILE *fptr; - struct Mdc_MatDir mlist[]; - Int32 lmax; -{ - Int32 blk, num_entry, num_stored, i; - Int32 nxtblk, matnum, strtblk, endblk, matstat; - Int32 dirbufr[MdcMatBLKSIZE/4]; - Uint8 bytebufr[MdcMatBLKSIZE]; - - blk = MdcMatFirstDirBlk; - num_entry = 0; - num_stored = 0; - while(1) { - mdc_mat_rblk( fptr, blk, bytebufr,1); - if ( MdcHostBig() ) { - MdcSWAB( (Uint8 *)bytebufr, (Uint8 *)dirbufr, MdcMatBLKSIZE); - MdcSWAW( (Uint16 *)dirbufr, (Uint16 *)dirbufr, MdcMatBLKSIZE/2); - }else{ - memcpy(dirbufr, bytebufr, MdcMatBLKSIZE); - } - /* nfree = dirbufr[0]; */ - nxtblk = dirbufr[1]; - /* prvblk = dirbufr[2]; */ - /* nused = dirbufr[3]; */ - for (i=4; iframe = matnum&0xFFF; - matval->plane = (matnum>>16)&0xFF; - matval->gate = (matnum>>24)&0x3F; - matval->data = (matnum>>30)&0x3; - matval->bed = (matnum>>12)&0xF; - return 0; -} -*/ - /******************************************************** -new version supporting 512 planes, 1024 planes, 8 data types */ - Int32 mdc_mat_numcod( frame, plane, gate, data, bed) - Int32 frame, plane, gate, data, bed; -{ - Int32 matnum8data16bed64gate1024plane512frame, loPlane, hiPlane = 0, loData, hiData = 0; - - hiPlane = (plane & 0x300); - loPlane = (plane & 0xFF); - loData = (data & 0x3); - hiData = (data & 0x4); - - matnum8data16bed64gate1024plane512frame = ((frame & 0x1FF) | ((bed & 0xF) << 12) | - ((loPlane << 16) | (hiPlane << 1)) | ((gate & 0x3F) << 24) | ((loData << 30) | (hiData << 9))); - - return (matnum8data16bed64gate1024plane512frame); -} - /******************************************************** -new version supporting 512 planes, 1024 planes, 8 data types */ - Int32 mdc_mat_numdoc( matnum, matval) - Int32 matnum; struct Mdc_Matval *matval; -{ - Int32 loPlane, hiPlane = 0, loData, hiData = 0; - - matval->frame = matnum & 0x1FF; - loPlane = (matnum >> 16) & 0xFF; - hiPlane = (matnum >> 1) & 0x300; - matval->plane = loPlane | hiPlane; - matval->gate = (matnum >> 24) & 0x3F; - loData = (matnum >> 30) & 0x3; - hiData = (matnum >> 9) & 0x4; - matval->data = loData | hiData; - matval->bed = (matnum >> 12) & 0xF; - return 0; -} - /*********************************************************/ - Int32 mdc_mat_lookup( fptr, matnum, entry) - FILE *fptr; Int32 matnum; struct Mdc_MatDir *entry; -{ - - Int32 blk, i; - Int32 nxtblk, matnbr, strtblk, endblk, matstat; - Int32 dirbufr[MdcMatBLKSIZE/4]; - Uint8 bytebufr[MdcMatBLKSIZE]; - - blk = MdcMatFirstDirBlk; - while(1) { - mdc_mat_rblk( fptr, blk, bytebufr,1); - if ( MdcHostBig() ) { - MdcSWAB( (Uint8 *)bytebufr, (Uint8 *)dirbufr, MdcMatBLKSIZE); - MdcSWAW( (Uint16 *)dirbufr, (Uint16 *)dirbufr, MdcMatBLKSIZE/2); - }else{ - memcpy(dirbufr, bytebufr, MdcMatBLKSIZE); - } - /* nfree = dirbufr[0]; */ - nxtblk = dirbufr[1]; - /* prvblk = dirbufr[2]; */ - /* nused = dirbufr[3]; */ - for (i=4; imatnum = matnbr; - entry->strtblk = strtblk; - entry->endblk = endblk; - entry->matstat = matstat; - return (1); } - } - blk = nxtblk; - if (blk == MdcMatFirstDirBlk) break; - } - return (0); -} - - /*********************************************************/ - Int32 mdc_mat_lookup7( fptr, matnum, entry) - FILE *fptr; Int32 matnum; struct Mdc_MatDir *entry; -{ - - Int32 blk, i; - Int32 nxtblk, matnbr, strtblk, endblk, matstat; - Int32 dirbufr[MdcMatBLKSIZE/4]; - Uint8 bytebufr[MdcMatBLKSIZE]; - - blk = MdcMatFirstDirBlk; - while(1) { - mdc_mat_rblk( fptr, blk, bytebufr,1); - if ( ! MdcHostBig() ) { - MdcSWAB( (Uint8 *)bytebufr, (Uint8 *)dirbufr, MdcMatBLKSIZE); - MdcSWAW( (Uint16 *)dirbufr, (Uint16 *)dirbufr, MdcMatBLKSIZE/2); - }else{ - memcpy(dirbufr, bytebufr, MdcMatBLKSIZE); - } - /* nfree = dirbufr[0]; */ - nxtblk = dirbufr[1]; - /* prvblk = dirbufr[2]; */ - /* nused = dirbufr[3]; */ - for (i=4; imatnum = matnbr; - entry->strtblk = strtblk; - entry->endblk = endblk; - entry->matstat = matstat; - return (1); } - } - blk = nxtblk; - if (blk == MdcMatFirstDirBlk) break; - } - return (0); -} - - /*********************************************************/ - Int32 mdc_mat_read_main_header( fptr, h) - FILE *fptr; Mdc_Main_header *h; -{ - Int16 b[256]; - char *bb; - Int32 err, i; - - err = mdc_mat_rblk(fptr,1,(Uint8 *)b,1);/* read main header at block 1*/ - if (err) return(err); - bb = (char *)b; - strncpy( h->original_file_name, bb+28, 20); - strncpy( h->node_id, bb+56, 10); - strncpy( h->isotope_code, bb+78, 8); - strncpy( h->radiopharmaceutical, bb+90, 32); - strncpy( h->study_name, bb+162, 12); - strncpy( h->patient_id, bb+174, 16); - strncpy( h->patient_name, bb+190, 32); - h->patient_sex = bb[222]; - strncpy( h->patient_age, bb+223, 10); - strncpy( h->patient_height, bb+233, 10); - strncpy( h->patient_weight, bb+243, 10); - h->patient_dexterity = bb[253]; - strncpy( h->physician_name, bb+254, 32); - strncpy( h->operator_name, bb+286, 32); - strncpy( h->study_description, bb+318, 32); - strncpy( h->facility_name, bb+356, 20); - strncpy( h->user_process_code, bb+462, 10); - if (MdcHostBig()) MdcSWAB( (Uint8 *)b, (Uint8 *)b, MdcMatBLKSIZE); - h->sw_version = b[24]; - h->data_type = b[25]; - h->system_type = b[26]; - h->file_type = b[27]; - h->scan_start_day = b[33]; - h->scan_start_month = b[34]; - h->scan_start_year = b[35]; - h->scan_start_hour = b[36]; - h->scan_start_minute = b[37]; - h->scan_start_second = b[38]; - h->isotope_halflife=mdc_get_vax_float((Uint16 *)b, 43); - h->gantry_tilt = mdc_get_vax_float((Uint16 *)b, 61); - h->gantry_rotation = mdc_get_vax_float((Uint16 *)b, 63); - h->bed_elevation = mdc_get_vax_float((Uint16 *)b, 65); - h->rot_source_speed = b[67]; - h->wobble_speed = b[68]; - h->transm_source_type = b[69]; - h->axial_fov = mdc_get_vax_float((Uint16 *)b, 70); - h->transaxial_fov = mdc_get_vax_float((Uint16 *)b, 72); - h->transaxial_samp_mode = b[74]; - h->coin_samp_mode = b[75]; - h->axial_samp_mode = b[76]; - h->calibration_factor=mdc_get_vax_float((Uint16 *)b, 77); - h->calibration_units = b[79]; - h->compression_code = b[80]; - h->acquisition_type = b[175]; - h->bed_type = b[176]; - h->septa_type = b[177]; - h->num_planes = b[188]; - h->num_frames = b[189]; - h->num_gates = b[190]; - h->num_bed_pos = b[191]; - h->init_bed_position=mdc_get_vax_float((Uint16 *)b, 192); - for (i=0; i<15; i++) - h->bed_offset[i] = mdc_get_vax_float((Uint16 *)b, 194+2*i); - h->plane_separation = mdc_get_vax_float((Uint16 *)b, 224); - h->lwr_sctr_thres = b[226]; - h->lwr_true_thres = b[227]; - h->upr_true_thres = b[228]; - h->collimator = mdc_get_vax_float((Uint16 *)b, 229); - h->acquisition_mode = b[236]; - return (0); -} - /*********************************************************/ - Int32 mdc_mat_read_matrix_data( fptr, blk, nblks, bufr) - FILE *fptr; Int32 blk, nblks; Int16 bufr[]; -{ - Int32 error ; - Mdc_Main_header h ; - - error = mdc_mat_read_main_header(fptr, &h) ; - if(error) return(error) ; - error = mdc_mat_read_mat_data(fptr, blk, nblks, - (Uint8 *)bufr, h.data_type) ; - return (error); -} - - /*********************************************************/ - Int32 mdc_mat_read_main_header7( fptr, h) - FILE *fptr; Mdc_Main_header7 *h; -{ - Int16 b[256]; - char *bb; - Int32 err, i; - - err = mdc_mat_rblk(fptr,1,(Uint8 *)b,1);/* read main header at block 1*/ - if (err) return(err); - bb = (char *)b; - - memcpy( h->magic_number ,bb ,14); - memcpy( h->original_file_name ,bb+14 ,32); - memcpy(&h->sw_version ,bb+46 , 2); MdcSWAP(h->sw_version); - memcpy(&h->system_type ,bb+48 , 2); MdcSWAP(h->system_type); - memcpy(&h->file_type ,bb+50 , 2); MdcSWAP(h->file_type); - memcpy( h->serial_number ,bb+52 ,10); - memcpy(&h->scan_start_time ,bb+62 , 4); MdcSWAP(h->scan_start_time); - memcpy( h->isotope_name ,bb+66 , 8); - memcpy(&h->isotope_halflife ,bb+74 , 4); MdcSWAP(h->isotope_halflife); - memcpy( h->radiopharmaceutical ,bb+78 ,32); - memcpy(&h->gantry_tilt ,bb+110, 4); MdcSWAP(h->gantry_tilt); - memcpy(&h->gantry_rotation ,bb+114, 4); MdcSWAP(h->gantry_rotation); - memcpy(&h->bed_elevation ,bb+118, 4); MdcSWAP(h->bed_elevation); - memcpy(&h->intrinsic_tilt ,bb+122, 4); MdcSWAP(h->intrinsic_tilt); - memcpy(&h->wobble_speed ,bb+126, 2); MdcSWAP(h->wobble_speed); - memcpy(&h->transm_source_type ,bb+128, 2); MdcSWAP(h->transm_source_type); - memcpy(&h->distance_scanned ,bb+130, 4); MdcSWAP(h->distance_scanned); - memcpy(&h->transaxial_fov ,bb+134, 4); MdcSWAP(h->transaxial_fov); - memcpy(&h->angular_compression ,bb+138, 2); MdcSWAP(h->angular_compression); - memcpy(&h->coin_samp_mode ,bb+140, 2); MdcSWAP(h->coin_samp_mode); - memcpy(&h->axial_samp_mode ,bb+142, 2); MdcSWAP(h->axial_samp_mode); - memcpy(&h->ecat_calibration_factor,bb+144,4); - MdcSWAP(h->ecat_calibration_factor); - memcpy(&h->calibration_units ,bb+148, 2); MdcSWAP(h->calibration_units); - memcpy(&h->calibration_units_label,bb+150,2); - MdcSWAP(h->calibration_units_label); - memcpy(&h->compression_code ,bb+152, 2); MdcSWAP(h->compression_code); - memcpy( h->study_type ,bb+154,12); - memcpy( h->patient_id ,bb+166,16); - memcpy( h->patient_name ,bb+182,32); - memcpy( h->patient_sex ,bb+214, 1); - memcpy( h->patient_dexterity ,bb+215, 1); - memcpy(&h->patient_age ,bb+216, 4); MdcSWAP(h->patient_age); - memcpy(&h->patient_height ,bb+220, 4); MdcSWAP(h->patient_height); - memcpy(&h->patient_weight ,bb+224, 4); MdcSWAP(h->patient_weight); - memcpy(&h->patient_birth_date ,bb+228, 4); MdcSWAP(h->patient_birth_date); - memcpy( h->physician_name ,bb+232,32); - memcpy( h->operator_name ,bb+264,32); - memcpy( h->study_description ,bb+296,32); - memcpy(&h->acquisition_type ,bb+328, 2); MdcSWAP(h->acquisition_type); - memcpy(&h->patient_orientation ,bb+330, 2); MdcSWAP(h->patient_orientation); - memcpy( h->facility_name ,bb+332,20); - memcpy(&h->num_planes ,bb+352, 2); MdcSWAP(h->num_planes); - memcpy(&h->num_frames ,bb+354, 2); MdcSWAP(h->num_frames); - memcpy(&h->num_gates ,bb+356, 2); MdcSWAP(h->num_gates); - memcpy(&h->num_bed_pos ,bb+358, 2); MdcSWAP(h->num_bed_pos); - memcpy(&h->init_bed_position ,bb+360, 4); MdcSWAP(h->init_bed_position); - memcpy( h->bed_position ,bb+364,60); - for (i=0; i<15; i++) MdcSWAP(h->bed_position[i]); - memcpy(&h->plane_separation ,bb+424, 4); MdcSWAP(h->plane_separation); - memcpy(&h->lwr_sctr_thres ,bb+428, 2); MdcSWAP(h->lwr_sctr_thres); - memcpy(&h->lwr_true_thres ,bb+430, 2); MdcSWAP(h->lwr_true_thres); - memcpy(&h->upr_true_thres ,bb+432, 2); MdcSWAP(h->upr_true_thres); - memcpy( h->user_process_code ,bb+434,10); - memcpy(&h->acquisition_mode ,bb+444, 2); MdcSWAP(h->acquisition_mode); - memcpy(&h->bin_size ,bb+446, 4); MdcSWAP(h->bin_size); - memcpy(&h->branching_fraction ,bb+450, 4); MdcSWAP(h->branching_fraction); - memcpy(&h->dose_start_time ,bb+454, 4); MdcSWAP(h->dose_start_time); - memcpy(&h->dosage ,bb+458, 4); MdcSWAP(h->dosage); - memcpy(&h->well_counter_corr_factor,bb+462,4); - MdcSWAP(h->well_counter_corr_factor); - memcpy( h->data_units ,bb+466,32); - memcpy(&h->septa_state ,bb+498, 2); MdcSWAP(h->septa_state); - memcpy( h->fill_cti ,bb+500,12); - - return (0); -} - -/*******************************************************************/ -/* May 90, PLuk - Now reads VAX or Sun matrix files. */ - -Int32 mdc_mat_read_mat_data( fptr, strtblk, nblks, dptr, dtype) - FILE *fptr; - Int32 strtblk, nblks, dtype; - Uint8 *dptr; -{ - Int32 i, error; - - error = mdc_mat_rblk( fptr, strtblk, dptr, nblks); - if (error) return(error); - - switch( dtype) - { - case 1: /* byte format...no translation necessary */ - break; - case 2: /* Vax I*2 */ - if (MdcHostBig()) - MdcSWAB((Uint8 *)dptr, (Uint8 *)dptr, 512*nblks); - break; - case 3: /* Vax I*4 */ - if (MdcHostBig()) { - MdcSWAB( (Uint8 *)dptr, (Uint8 *)dptr, 512*nblks); - MdcSWAW( (Uint16 *)dptr, (Uint16 *)dptr, 256*nblks); - } - break; - case 4: /* Vax R*4 */ - if (MdcHostBig()) - MdcSWAB( (Uint8 *)dptr, (Uint8 *)dptr, 512*nblks); - for (i=0; idata_type = b[63]; - h->dimension_1 = b[66]; - h->dimension_2 = b[67]; - h->smoothing = b[68]; - h->processing_code = b[69]; - h->sample_distance = mdc_get_vax_float((Uint16 *)b, 73); - h->isotope_halflife = mdc_get_vax_float((Uint16 *)b, 83); - h->frame_duration_sec = b[85]; - h->gate_duration = mdc_get_vax_long((Uint16 *)b, 86); - h->r_wave_offset = mdc_get_vax_long((Uint16 *)b, 88); - h->scale_factor = mdc_get_vax_float((Uint16 *)b, 91); - h->scan_min = b[96]; - h->scan_max = b[97]; - h->prompts = mdc_get_vax_long((Uint16 *)b, 98); - h->delayed = mdc_get_vax_long((Uint16 *)b, 100); - h->multiples = mdc_get_vax_long((Uint16 *)b, 102); - h->net_trues = mdc_get_vax_long((Uint16 *)b, 104); - for (i=0; i<16; i++) - { h->cor_singles[i] = mdc_get_vax_float((Uint16 *)b, 158+2*i); - h->uncor_singles[i] = mdc_get_vax_float((Uint16 *)b, 190+2*i);} - h->tot_avg_cor = mdc_get_vax_float((Uint16 *)b, 222); - h->tot_avg_uncor = mdc_get_vax_float((Uint16 *)b, 224); - h->total_coin_rate = mdc_get_vax_long((Uint16 *)b, 226); - h->frame_start_time = mdc_get_vax_long((Uint16 *)b, 228); - h->frame_duration = mdc_get_vax_long((Uint16 *)b, 230); - h->loss_correction_fctr = mdc_get_vax_float((Uint16 *)b, 232); - for (i=0; i<8; i++) - h->phy_planes[i] = mdc_get_vax_long((Uint16 *)b, 234+(2*i)); - return (0); -} - /*********************************************************/ - Int32 mdc_mat_read_scan_subheader7( fptr, blknum, h) - FILE *fptr; Int32 blknum; Mdc_Scan_subheader7 *h; -{ - Int16 b[256]; - Int32 err; - char *bb; - - err = mdc_mat_rblk( fptr, blknum, (Uint8 *)b, 1); - if (err) return(err); - bb = (char *)b; - - memcpy(&h->data_type ,bb , 2); MdcSWAP(h->data_type); - memcpy(&h->num_dimensions ,bb+ 2, 2); MdcSWAP(h->num_dimensions); - memcpy(&h->num_r_elements ,bb+ 4, 2); MdcSWAP(h->num_r_elements); - memcpy(&h->num_angles ,bb+ 6, 2); MdcSWAP(h->num_angles); - memcpy(&h->corrections_applied ,bb+ 8, 2); MdcSWAP(h->corrections_applied); - memcpy(&h->num_z_elements ,bb+ 10, 2); MdcSWAP(h->num_z_elements); - memcpy(&h->ring_difference ,bb+ 12, 2); MdcSWAP(h->ring_difference); - memcpy(&h->x_resolution ,bb+ 14, 4); MdcSWAP(h->x_resolution); - memcpy(&h->y_resolution ,bb+ 18, 4); MdcSWAP(h->y_resolution); - memcpy(&h->z_resolution ,bb+ 22, 4); MdcSWAP(h->z_resolution); - memcpy(&h->w_resolution ,bb+ 26, 4); MdcSWAP(h->w_resolution); - - return (0); -} - /*********************************************************/ - Int32 mdc_mat_read_image_subheader( fptr, blknum, h) - FILE *fptr; Int32 blknum; Mdc_Image_subheader *h; -{ - Int16 b[256]; - Int32 i, err; - char *bb; - - err = mdc_mat_rblk( fptr, blknum, (Uint8 *)b, 1); - if (err) return(err); - bb = (char *)b; - strncpy( h->annotation, bb+420, 40); - if (MdcHostBig()) - MdcSWAB( (Uint8 *)b, (Uint8 *)b, MdcMatBLKSIZE); - h->data_type = b[63]; - h->num_dimensions = b[64]; - h->dimension_1 = b[66]; - h->dimension_2 = b[67]; - h->x_origin = mdc_get_vax_float((Uint16 *)b, 80); - h->y_origin = mdc_get_vax_float((Uint16 *)b, 82); - h->recon_scale = mdc_get_vax_float((Uint16 *)b, 84); - h->quant_scale = mdc_get_vax_float((Uint16 *)b, 86); - h->image_min = b[88]; - h->image_max = b[89]; - h->pixel_size = mdc_get_vax_float((Uint16 *)b, 92); - h->slice_width = mdc_get_vax_float((Uint16 *)b, 94); - h->frame_duration = mdc_get_vax_long((Uint16 *)b, 96); - h->frame_start_time = mdc_get_vax_long((Uint16 *)b, 98); - h->slice_location = b[100]; - h->recon_start_hour = b[101]; - h->recon_start_minute = b[102]; - h->recon_start_sec = b[103]; - h->gate_duration = mdc_get_vax_long((Uint16 *)b, 104); - h->filter_code = b[118]; - h->scan_matrix_num = mdc_get_vax_long((Uint16 *)b, 119); - h->norm_matrix_num = mdc_get_vax_long((Uint16 *)b, 121); - h->atten_cor_matrix_num = mdc_get_vax_long((Uint16 *)b, 123); - h->image_rotation = mdc_get_vax_float((Uint16 *)b, 148); - h->plane_eff_corr_fctr = mdc_get_vax_float((Uint16 *)b, 150); - h->decay_corr_fctr = mdc_get_vax_float((Uint16 *)b, 152); - h->loss_corr_fctr = mdc_get_vax_float((Uint16 *)b, 154); - h->intrinsic_tilt = mdc_get_vax_float((Uint16 *)b, 156); - h->processing_code = b[188]; - h->quant_units = b[190]; - h->recon_start_day = b[191]; - h->recon_start_month = b[192]; - h->recon_start_year = b[193]; - h->ecat_calibration_fctr = mdc_get_vax_float((Uint16 *)b, 194); - h->well_counter_cal_fctr = mdc_get_vax_float((Uint16 *)b, 196); - for (i=0; i<6; i++) - h->filter_params[i] = mdc_get_vax_float((Uint16 *)b, 198+2*i); - return (0); -} - /*********************************************************/ - Int32 mdc_mat_read_image_subheader7( fptr, blknum, h) - FILE *fptr; Int32 blknum; Mdc_Image_subheader7 *h; -{ - Int16 b[256]; - Int32 i, err; - char *bb; - - err = mdc_mat_rblk( fptr, blknum, (Uint8 *)b, 1); - if (err) return(err); - bb = (char *)b; - - memcpy(&h->data_type ,bb , 2); MdcSWAP(h->data_type); - memcpy(&h->num_dimensions ,bb+ 2, 2); MdcSWAP(h->num_dimensions); - memcpy(&h->x_dimension ,bb+ 4, 2); MdcSWAP(h->x_dimension); - memcpy(&h->y_dimension ,bb+ 6, 2); MdcSWAP(h->y_dimension); - memcpy(&h->z_dimension ,bb+ 8, 2); MdcSWAP(h->z_dimension); - memcpy(&h->x_offset ,bb+ 10, 4); MdcSWAP(h->x_offset); - memcpy(&h->y_offset ,bb+ 14, 4); MdcSWAP(h->y_offset); - memcpy(&h->z_offset ,bb+ 18, 4); MdcSWAP(h->z_offset); - memcpy(&h->recon_zoom ,bb+ 22, 4); MdcSWAP(h->recon_zoom); - memcpy(&h->scale_factor ,bb+ 26, 4); MdcSWAP(h->scale_factor); - memcpy(&h->image_min ,bb+ 30, 2); MdcSWAP(h->image_min); - memcpy(&h->image_max ,bb+ 32, 2); MdcSWAP(h->image_max); - memcpy(&h->x_pixel_size ,bb+ 34, 4); MdcSWAP(h->x_pixel_size); - memcpy(&h->y_pixel_size ,bb+ 38, 4); MdcSWAP(h->y_pixel_size); - memcpy(&h->z_pixel_size ,bb+ 42, 4); MdcSWAP(h->z_pixel_size); - memcpy(&h->frame_duration ,bb+ 46, 4); MdcSWAP(h->frame_duration); - memcpy(&h->frame_start_time ,bb+ 50, 4); MdcSWAP(h->frame_start_time); - memcpy(&h->filter_code ,bb+ 54, 2); MdcSWAP(h->filter_code); - memcpy(&h->x_resolution ,bb+ 56, 4); MdcSWAP(h->x_resolution); - memcpy(&h->y_resolution ,bb+ 60, 4); MdcSWAP(h->y_resolution); - memcpy(&h->z_resolution ,bb+ 64, 4); MdcSWAP(h->z_resolution); - memcpy(&h->num_r_elements ,bb+ 68, 4); MdcSWAP(h->num_r_elements); - memcpy(&h->num_angles ,bb+ 72, 4); MdcSWAP(h->num_angles); - memcpy(&h->z_rotation_angle ,bb+ 76, 4); MdcSWAP(h->z_rotation_angle); - memcpy(&h->decay_corr_fctr ,bb+ 80, 4); MdcSWAP(h->decay_corr_fctr); - memcpy(&h->processing_code ,bb+ 84, 4); MdcSWAP(h->processing_code); - memcpy(&h->gate_duration ,bb+ 88, 4); MdcSWAP(h->gate_duration); - memcpy(&h->r_wave_offset ,bb+ 92, 4); MdcSWAP(h->r_wave_offset); - memcpy(&h->num_accepted_beats ,bb+ 96, 4); MdcSWAP(h->num_accepted_beats); - memcpy(&h->filter_cutoff_frequency,bb+100, 4); - MdcSWAP(h->filter_cutoff_frequency); - memcpy(&h->filter_resolution ,bb+104, 4); MdcSWAP(h->filter_resolution); - memcpy(&h->filter_ramp_slope ,bb+108, 4); MdcSWAP(h->filter_ramp_slope); - memcpy(&h->filter_order ,bb+112, 2); MdcSWAP(h->filter_order); - memcpy(&h->filter_scatter_fraction,bb+114, 4); - MdcSWAP(h->filter_scatter_fraction); - memcpy(&h->filter_scatter_slope ,bb+118, 4); - MdcSWAP(h->filter_scatter_slope); - memcpy( h->annotation ,bb+122,40); - memcpy(&h->mt_1_1 ,bb+162, 4); MdcSWAP(h->mt_1_1); - memcpy(&h->mt_1_2 ,bb+166, 4); MdcSWAP(h->mt_1_2); - memcpy(&h->mt_1_3 ,bb+170, 4); MdcSWAP(h->mt_1_3); - memcpy(&h->mt_2_1 ,bb+174, 4); MdcSWAP(h->mt_2_1); - memcpy(&h->mt_2_2 ,bb+178, 4); MdcSWAP(h->mt_2_2); - memcpy(&h->mt_2_3 ,bb+182, 4); MdcSWAP(h->mt_2_3); - memcpy(&h->mt_3_1 ,bb+186, 4); MdcSWAP(h->mt_3_1); - memcpy(&h->mt_3_2 ,bb+190, 4); MdcSWAP(h->mt_3_2); - memcpy(&h->mt_3_3 ,bb+194, 4); MdcSWAP(h->mt_3_3); - memcpy(&h->rfilter_cutoff ,bb+198, 4); MdcSWAP(h->rfilter_cutoff); - memcpy(&h->rfilter_resolution ,bb+202, 4); MdcSWAP(h->rfilter_resolution); - memcpy(&h->rfilter_code ,bb+206, 2); MdcSWAP(h->rfilter_code); - memcpy(&h->rfilter_order ,bb+208, 2); MdcSWAP(h->rfilter_order); - memcpy(&h->zfilter_cutoff ,bb+210, 4); MdcSWAP(h->zfilter_cutoff); - memcpy(&h->zfilter_resolution ,bb+214, 4); MdcSWAP(h->zfilter_resolution); - memcpy(&h->zfilter_code ,bb+218, 2); MdcSWAP(h->zfilter_code); - memcpy(&h->zfilter_order ,bb+220, 2); MdcSWAP(h->zfilter_order); - memcpy(&h->mt_1_4 ,bb+222, 4); MdcSWAP(h->mt_1_4); - memcpy(&h->mt_2_4 ,bb+226, 4); MdcSWAP(h->mt_2_4); - memcpy(&h->mt_3_4 ,bb+230, 4); MdcSWAP(h->mt_3_4); - memcpy(&h->scatter_type ,bb+234, 2); MdcSWAP(h->scatter_type); - memcpy(&h->recon_type ,bb+236, 2); MdcSWAP(h->recon_type); - memcpy(&h->recon_views ,bb+238, 2); MdcSWAP(h->recon_views); - memcpy( h->fill_cti ,bb+240,174); - for (i=0; i<87; i++) MdcSWAP(h->fill_cti[i]); - memcpy( h->fill_user ,bb+414,96); - for (i=0; i<48; i++) MdcSWAP(h->fill_user[i]); - - return (0); -} - - - /*********************************************************/ - float mdc_get_vax_float( bufr, off) - Uint16 bufr[]; Int32 off; -{ - Uint16 t1, t2; - union {Uint32 t3; float t4;} test; - - if (bufr[off]==0 && bufr[off+1]==0) return(0.0); - t1 = bufr[off] & 0x80ff; - t2=(((bufr[off])&0x7f00)+0xff00)&0x7f00; - test.t3 = (t1+t2)<<16; - test.t3 =test.t3+bufr[off+1]; - return(test.t4); -} - - /*********************************************************/ - Int32 mdc_get_vax_long( bufr, off) - Uint16 bufr[]; Int32 off; -{ - return ((bufr[off+1]<<16)+bufr[off]); -} - -Mdc_Mat_dir mdc_mat_read_dir( fptr, selector) - FILE *fptr; - Uint8 *selector; -{ Int32 i, n, blk, nxtblk, ndblks, bufr[128]; - Mdc_Mat_dir dir; - - blk = MdcMatFirstDirBlk; - nxtblk = 0; - for (ndblks=0; nxtblk != MdcMatFirstDirBlk; ndblks++) - { - mdc_mat_rblk( fptr, blk, (Uint8 *)bufr, 1); - if (MdcHostBig()) { - MdcSWAB( (Uint8 *)bufr, (Uint8 *)bufr, 8); - MdcSWAW( (Uint16 *)bufr, (Uint16 *)bufr, 4); - } - nxtblk = bufr[1]; - blk = nxtblk; - } - dir = (Mdc_Mat_dir) malloc( sizeof(struct mdc_matdir)); - dir->nmats = 0; - dir->nmax = 31 * ndblks; - dir->entry = (struct Mdc_MatDir *) malloc( 31*ndblks*sizeof( struct Mdc_MatDir)); - for (n=0, nxtblk=0, blk=MdcMatFirstDirBlk; nxtblk != MdcMatFirstDirBlk; blk = nxtblk) - { - mdc_mat_rblk( fptr, blk, (Uint8 *)bufr, 1); - if (MdcHostBig()) { - MdcSWAB( (Uint8 *)bufr, (Uint8 *)bufr, 512); - MdcSWAW( (Uint16 *)bufr, (Uint16 *)bufr, 256); - } - nxtblk = bufr[1]; - for (i=4; ientry[n].matnum = bufr[i++]; - dir->entry[n].strtblk = bufr[i++]; - dir->entry[n].endblk = bufr[i++]; - dir->entry[n].matstat = bufr[i++]; - if (dir->entry[n].matnum != 0) dir->nmats++; - } - } - return dir; -} - -/*********************************************************/ - -Int32 mdc_mat_wblk( fptr, blkno, bufr, nblks) -FILE *fptr; -Int32 blkno, nblks; -Uint8 *bufr; -{ - Int32 err; - /* seek to position in file */ - err=fseek( fptr, (blkno-1)*MdcMatBLKSIZE, 0); - if (err) return(-1); - - /* write matrix data */ - err=fwrite( bufr, 1, (unsigned)nblks*MdcMatBLKSIZE, fptr); - if (err != nblks*MdcMatBLKSIZE) return(-1); - if (ferror(fptr)) return (-1); - return (0); -} - -FILE *mdc_mat_create( fname, mhead) - char *fname; - Mdc_Main_header *mhead; -{ - FILE *fptr; - Int32 i, *bufr; - fptr = mdc_mat_open( fname, "wb+"); - if (!fptr) return fptr; - mdc_mat_write_main_header( fptr, mhead); - bufr = (Int32 *) malloc( MdcMatBLKSIZE); - for (i=0; i<128; i++) - bufr[i] = 0; - bufr[0] = 31; - bufr[1] = 2; - if (MdcHostBig()) { - MdcSWAW( (Uint16 *)bufr, (Uint16 *)bufr, 256); - MdcSWAB( (Uint8 *)bufr, (Uint8 *)bufr, 512); - } - mdc_mat_wblk( fptr, MdcMatFirstDirBlk, (Uint8 *)bufr, 1); - free( bufr); - return (fptr); -} - -Int32 mdc_mat_enter( fptr, matnum, nblks) - FILE *fptr; Int32 matnum, nblks; -{ - - Int32 dirblk, dirbufr[128], i, nxtblk, busy, oldsize; - - dirblk = MdcMatFirstDirBlk; - mdc_mat_rblk( fptr, dirblk, (Uint8 *)dirbufr, 1); - if (MdcHostBig()) { - MdcSWAB( (Uint8 *)dirbufr, (Uint8 *)dirbufr, 512); - MdcSWAW( (Uint16 *)dirbufr, (Uint16 *)dirbufr, 256); - } - busy = 1; - while (busy) { - nxtblk = dirblk+1; - for (i=4; i<128; i+=4) - { - if (dirbufr[i] == 0) - { busy = 0; - break; - } - else if (dirbufr[i] == matnum) - { oldsize = dirbufr[i+2]-dirbufr[i+1]+1; - if (oldsize < nblks) - { dirbufr[i] = 0xFFFFFFFF; - if (MdcHostBig()) { - MdcSWAW( (Uint16 *)dirbufr, (Uint16 *)dirbufr, 256); - MdcSWAB( (Uint8 *)dirbufr, (Uint8 *)dirbufr, 512); - } - mdc_mat_wblk( fptr, dirblk, (Uint8 *)dirbufr, 1); - if (MdcHostBig()) { - MdcSWAB( (Uint8 *)dirbufr, (Uint8 *)dirbufr, 512); - MdcSWAW( (Uint16 *)dirbufr, (Uint16 *)dirbufr, 256); - } - nxtblk = dirbufr[i+2]+1; - } - else - { nxtblk = dirbufr[i+1]; - dirbufr[0]++; - dirbufr[3]--; - busy = 0; - break; - } - } - else nxtblk = dirbufr[i+2]+1; - } - if (!busy) break; - if (dirbufr[1] != MdcMatFirstDirBlk) - { dirblk = dirbufr[1]; - mdc_mat_rblk( fptr, dirblk, (Uint8 *)dirbufr, 1); - if (MdcHostBig()) { - MdcSWAB( (Uint8 *)dirbufr, (Uint8 *)dirbufr, 512); - MdcSWAW( (Uint16 *)dirbufr, (Uint16 *)dirbufr, 256); - } - } else - { dirbufr[1] = nxtblk; - if (MdcHostBig()) { - MdcSWAW( (Uint16 *)dirbufr, (Uint16 *)dirbufr, 256); - MdcSWAB( (Uint8 *)dirbufr, (Uint8 *)dirbufr, 512); - } - mdc_mat_wblk( fptr, dirblk, (Uint8 *)dirbufr, 1); - dirbufr[0] = 31; - dirbufr[1] = MdcMatFirstDirBlk; - dirbufr[2] = dirblk; - dirbufr[3] = 0; - dirblk = nxtblk; - for (i=4; i<128; i++) dirbufr[i] = 0; - } - } - dirbufr[i] = matnum; - dirbufr[i+1] = nxtblk; - dirbufr[i+2] = nxtblk + nblks; - dirbufr[i+3] = 1; - dirbufr[0]--; - dirbufr[3]++; - if (MdcHostBig()) { - MdcSWAW( (Uint16 *)dirbufr, (Uint16 *)dirbufr, 256); - MdcSWAB( (Uint8 *)dirbufr, (Uint8 *)dirbufr, 512); - } - mdc_mat_wblk( fptr, dirblk, (Uint8 *)dirbufr, 1); - return (nxtblk); -} - -Int32 mdc_mat_write_image( fptr, matnum, header, data, data_size) - FILE *fptr; - Int32 matnum; - Mdc_Image_subheader *header; - Uint16 *data; - Int32 data_size; -{ - Int32 nxtblk, size, error ; - - size = (data_size+511)/512; - nxtblk = mdc_mat_enter( fptr, matnum, size); - mdc_mat_write_image_subheader( fptr, nxtblk, header); - error = mdc_write_matrix_data(fptr, nxtblk+1, size, - (Uint8 *)data, - header->data_type) ; - return(error) ; -} - -Int32 mdc_mat_write_scan( fptr, matnum, header, data, data_size) - FILE *fptr; - Int32 matnum; - Mdc_Scan_subheader *header; - Uint16 *data; - Int32 data_size; -{ - Int32 nxtblk, size, error ; - - size = (data_size+511)/512; - nxtblk = mdc_mat_enter( fptr, matnum, size); - mdc_mat_write_scan_subheader( fptr, nxtblk, header); - error = mdc_write_matrix_data(fptr, nxtblk+1, size, - (Uint8 *)data, - header->data_type) ; - return(error) ; -} - -Int32 mdc_mat_write_attn( fptr, matnum, header, data, data_size) - FILE *fptr; - Int32 matnum; - Mdc_Attn_subheader *header; - float *data; - Int32 data_size; -{ - Int32 nxtblk, size, error ; - - size = (data_size+511)/512; - nxtblk = mdc_mat_enter( fptr, matnum, size); - mdc_mat_write_attn_subheader( fptr, nxtblk, header); - error = mdc_write_matrix_data (fptr, nxtblk+1, size, - (Uint8 *)data, - header->data_type) ; - return(error) ; -} - -Int32 mdc_mat_write_norm( fptr, matnum, header, data, data_size) - FILE *fptr; - Int32 matnum; - Mdc_Norm_subheader *header; - float *data; - Int32 data_size; -{ - Int32 nxtblk, size, error ; - - size = (data_size+511)/512; - nxtblk = mdc_mat_enter( fptr, matnum, size); - mdc_mat_write_norm_subheader( fptr, nxtblk, header); - error = mdc_write_matrix_data(fptr, nxtblk+1, size, - (Uint8 *)data, - header->data_type) ; - return(error) ; -} - -Int32 mdc_mat_write_idata( fptr, blk, data, size) - FILE *fptr; - Int32 blk, size; - Uint8 *data; -{ - Uint8 bufr[512]; - Int32 i, nbytes, nblks; - - nblks = (size+511)/512; - for (i=0; i ranges[1][0]) return (0); - if (ranges[0][1] != -1) - if (m.plane < ranges[0][1] || m.plane > ranges[1][1]) return (0); - if (ranges[0][2] != -1) - if (m.gate < ranges[0][2] || m.gate > ranges[1][2]) return (0); - if (ranges[0][3] != -1) - if (m.data < ranges[0][3] || m.data > ranges[1][3]) return (0); - if (ranges[0][4] != -1) - if (m.bed < ranges[0][4] || m.bed > ranges[1][4]) return (0); - return (matnum); -} - -Int32 mdc_decode_selector( s1, ranges) - char *s1; Int32 ranges[2][5]; -{ char xword[16]; - Int32 i; - - mdc_fix_selector( s1, s1); - for (i=0;i<5;i++) /* set all ranges to all (-1) */ - { ranges[0][i]=ranges[1][i]=-1; - s1 = mdc_nex_word( s1, xword); - if (xword[0] == '*') continue; - else if (strchr(xword,':')) - sscanf(xword,"%d:%d",&ranges[0][i],&ranges[1][i]); - else - { sscanf(xword,"%d",&ranges[0][i]); - ranges[1][i]=ranges[0][i]; - }; - } - return 0; -} - -Int32 mdc_str_find( s1, s2) - char *s1, *s2; -{ - Int32 i, j, k; - - for (i=0;s1[i];i++) { - for (j=i,k=0; s2[k]!='\0' && s1[j]==s2[k]; j++, k++) ; - if (s2[k]=='\0') return (i); - } return (-1); -} - -Int32 mdc_str_replace( s1, s2, s3, s4) - char *s1, *s2, *s3, *s4; -{ - Int32 nf=0, n; - - *s1 = '\0'; - while (1) - { if ((n=mdc_str_find(s2, s3))==-1) - { strcat(s1, s2); - return (nf); - } else - { strncat(s1, s2, (unsigned)n); - strcat(s1, s4); - s2+= n+strlen(s3); - nf++; - } - } -} - -Int32 mdc_string_replace( s1, s2, s3, s4) - char *s1, *s2, *s3, *s4; -{ - char temp[256]; - - strcpy(temp, s2); - while (mdc_str_replace(s1, temp, s3, s4) > 0) - strcpy(temp, s1); - return 0; -} - -Int32 mdc_fix_selector( s1, s2) - char *s1, *s2; -{ - char temp[256]; - mdc_string_replace(temp, s2, "," , " "); - mdc_string_replace(s1, temp, "..", ":"); - mdc_string_replace(temp, s1, ".", ":"); - mdc_string_replace(s1, temp, "-", ":"); - mdc_string_replace(temp, s1, "**", "*"); - mdc_string_replace(s1, temp, " ", " "); - mdc_string_replace(temp, s1, " :", ":"); - mdc_string_replace(s1, temp, ": ", ":"); - return 0; -} - -char* mdc_nex_word(s, w) - char *s, *w; -{ - while (*s && *s!=' ') *w++=*s++; - *w='\0'; - if (*s) s++; - return (s); -} - -/********************************************************/ -/* HOSTFTOVAXF */ -/********************************************************/ - -Int32 mdc_hostftovaxf(float f_orig, Uint16 number[]) -{ - - /* convert from host float to vax float */ - - union { - Uint16 t[2]; - float t4; - } test ; - Uint16 exp; - - number[0] = 0; - number[1] = 0; - - test.t4 = f_orig; - if (test.t4 == 0.0) - return 0; - - if (!MdcHostBig()) MdcSWAW((Uint16 *)test.t, (Uint16 *)test.t,2); - - number[1] = test.t[1]; - - exp = ((test.t[0] & 0x7f00) + 0x0100) & 0x7f00; - test.t[0] = (test.t[0] & 0x80ff) + exp; - - number[0] = test.t[0]; - return 0; - -} - -/*********************************************************/ -Int32 mdc_mat_write_main_header( fptr, header) -FILE *fptr; Mdc_Main_header *header; -{ - Uint8 *bbufr; - Int16 bufr[256]; - Int32 err,i; - - for (i=0; i<256; i++) - bufr[i] = 0; - bbufr = (Uint8 *) bufr; - - bufr[24] = header->sw_version; - bufr[25] = header->data_type; - bufr[26] = header->system_type; - bufr[27] = header->file_type; - bufr[33] = header->scan_start_day; - bufr[34] = header->scan_start_month; - bufr[35] = header->scan_start_year; - bufr[36] = header->scan_start_hour; - bufr[37] = header->scan_start_minute; - bufr[38] = header->scan_start_second; - mdc_hostftovaxf (header->isotope_halflife, (Uint16 *)&bufr[43]); - mdc_hostftovaxf (header->gantry_tilt, (Uint16 *)&bufr[61]); - mdc_hostftovaxf (header->gantry_rotation, (Uint16 *)&bufr[63]); - mdc_hostftovaxf (header->bed_elevation, (Uint16 *)&bufr[65]); - bufr[67] = header->rot_source_speed; - bufr[68] = header->wobble_speed; - bufr[69] = header->transm_source_type; - mdc_hostftovaxf (header->axial_fov, (Uint16 *)&bufr[70]); - mdc_hostftovaxf (header->transaxial_fov, (Uint16 *)&bufr[72]); - bufr[74] = header->transaxial_samp_mode; - bufr[75] = header->coin_samp_mode; - bufr[76] = header->axial_samp_mode; - mdc_hostftovaxf (header->calibration_factor,(Uint16 *)&bufr[77]); - bufr[79] = header->calibration_units; - bufr[80] = header->compression_code; - bufr[175] = header->acquisition_type; - bufr[176] = header->bed_type; - bufr[177] = header->septa_type; - bufr[188] = header->num_planes; - bufr[189] = header->num_frames; - bufr[190] = header->num_gates; - bufr[191] = header->num_bed_pos; - mdc_hostftovaxf (header->init_bed_position,(Uint16 *)&bufr[192]); - for (i=0; i<15; i++) - { - mdc_hostftovaxf (header->bed_offset[i],(Uint16 *)&bufr[194+2*i]); - } - mdc_hostftovaxf (header->plane_separation,(Uint16 *)&bufr[224]); - bufr[226] = header->lwr_sctr_thres; - bufr[227] = header->lwr_true_thres; - bufr[228] = header->upr_true_thres; - mdc_hostftovaxf (header->collimator,(Uint16 *)&bufr[229]); - bufr[236] = header->acquisition_mode; - - if (MdcHostBig()) - MdcSWAB( (Uint8 *)bufr, (Uint8 *)bufr, MdcMatBLKSIZE); - - memcpy( bbufr+28, header->original_file_name, 20); - /* write the node_id - character string */ - memcpy( bbufr+56, header->node_id, 10); - /* write the isotope code - char string */ - memcpy( bbufr+78, header->isotope_code, 8); - /* write the radiopharmaceutical - char string */ - memcpy( bbufr+90, header->radiopharmaceutical, 32); - /* study_name - char string */ - memcpy( bbufr+162, header->study_name, 12); - /* patient_id - char string */ - memcpy( bbufr+174, header->patient_id, 16); - /* patient_name - char string */ - memcpy( bbufr+190, header->patient_name, 32); - /* patient_sex - char */ - bbufr[222] = header->patient_sex; - /* patient_age - char string */ - memcpy( bbufr+223, header->patient_age, 10); - /* patient_height - char string */ - memcpy( bbufr+233, header->patient_height, 10); - /* patient_weight - char string */ - memcpy( bbufr+243, header->patient_weight, 10); - /* patient_dexterity - char */ - bbufr[253] = header->patient_dexterity; - /* physician_name - char string */ - memcpy( bbufr+254, header->physician_name, 32); - /* operator_name - char string */ - memcpy( bbufr+286, header->operator_name, 32); - /* study_description - char string */ - memcpy( bbufr+318, header->study_description, 32); - /* facility_name */ - memcpy( bbufr+356, header->facility_name, 20); - /* user_process_code - char string */ - memcpy( bbufr+462, header->user_process_code, 10); - - err = mdc_mat_wblk( fptr, 1, (Uint8 *)bufr, 1); /* write main header at block 1 */ - if (err) return(err); - - return (0); -} - -/*********************************************************/ - -Int32 mdc_mat_write_image_subheader( fptr, blknum, header) -FILE *fptr; Int32 blknum; Mdc_Image_subheader *header; -{ - Uint8 *bbufr; - Int16 bufr[256]; - Int32 i, err; - - for (i=0; i<256; i++) - bufr[i] = 0; - bbufr = (Uint8 *) bufr; - /* transfer subheader information */ - bufr[63] = header->data_type; - bufr[64] = header->num_dimensions; - bufr[66] = header->dimension_1; - bufr[67] = header->dimension_2; - mdc_hostftovaxf(header->x_origin,(Uint16 *)&bufr[80]); - mdc_hostftovaxf(header->y_origin,(Uint16 *)&bufr[82]); - mdc_hostftovaxf(header->recon_scale,(Uint16 *)&bufr[84]); - mdc_hostftovaxf(header->quant_scale,(Uint16 *)&bufr[86]); - bufr[88] = header->image_min; - bufr[89] = header->image_max; - mdc_hostftovaxf(header->pixel_size,(Uint16 *)&bufr[92]); - mdc_hostftovaxf(header->slice_width,(Uint16 *)&bufr[94]); - mdc_hostltovaxl(header->frame_duration,(Uint16 *)&bufr[96]); - mdc_hostltovaxl(header->frame_start_time,(Uint16 *)&bufr[98]); - bufr[100] = header->slice_location; - bufr[101] = header->recon_start_hour; - bufr[102] = header->recon_start_minute; - bufr[103] = header->recon_start_sec; - mdc_hostltovaxl(header->gate_duration,(Uint16 *)&bufr[104]); - bufr[118] = header->filter_code; - mdc_hostltovaxl(header->scan_matrix_num,(Uint16 *)&bufr[119]); - mdc_hostltovaxl(header->norm_matrix_num,(Uint16 *)&bufr[121]); - mdc_hostltovaxl(header->atten_cor_matrix_num,(Uint16 *)&bufr[123]); - mdc_hostftovaxf(header->image_rotation,(Uint16 *)&bufr[148]); - mdc_hostftovaxf(header->plane_eff_corr_fctr,(Uint16 *)&bufr[150]); - mdc_hostftovaxf(header->decay_corr_fctr,(Uint16 *)&bufr[152]); - mdc_hostftovaxf(header->loss_corr_fctr,(Uint16 *)&bufr[154]); - mdc_hostftovaxf(header->intrinsic_tilt,(Uint16 *)&bufr[156]); - bufr[188] = header->processing_code; - bufr[190] = header->quant_units; - bufr[191] = header->recon_start_day; - bufr[192] = header->recon_start_month; - bufr[193] = header->recon_start_year; - mdc_hostftovaxf(header->ecat_calibration_fctr,(Uint16 *)&bufr[194]); - mdc_hostftovaxf(header->well_counter_cal_fctr,(Uint16 *)&bufr[196]); - - for (i=0; i<6; i++) - mdc_hostftovaxf(header->filter_params[i],(Uint16 *)&bufr[198+2*i]); - - /* swap the bytes */ - if (MdcHostBig()) - MdcSWAB( (Uint8 *)bufr, (Uint8 *)bufr, MdcMatBLKSIZE); - - strcpy ((char *)(bbufr+420), header->annotation); - - /* write to matrix file */ - err = mdc_mat_wblk( fptr, blknum, bbufr, 1); - if (err) return(err); - - return(0); -} - -/*********************************************************/ -Int32 mdc_hostltovaxl( in, out) - Int32 in; - Uint16 out[2]; -{ - - out[0]=(in&0x0000FFFF); - out[1]=(in&0xFFFF0000)>>16; - - return 0; -} - -/*********************************************************/ -Int32 mdc_mat_write_scan_subheader( fptr, blknum, header) - FILE *fptr; - Int32 blknum; - Mdc_Scan_subheader *header; -{ - Int16 bufr[256]; - Int32 i, err; - - for (i=0; i<256; bufr[i++]=0); - bufr[0] = 256; - bufr[1] = 1; - bufr[2] = 22; - bufr[3] = -1; - bufr[4] = 25; - bufr[5] = 62; - bufr[6] = 79; - bufr[7] = 106; - bufr[24] = 37; - bufr[25] = -1; - bufr[61] = 17; - bufr[62] = -1; - bufr[78] = 27; - bufr[79] = -1; - bufr[105] = 52; - bufr[106] = -1; - bufr[63] = header->data_type; - bufr[66] = header->dimension_1; /* x dimension */ - bufr[67] = header->dimension_2; /* y_dimension */ - bufr[68] = header->smoothing; - bufr[69] = header->processing_code; - mdc_hostftovaxf(header->sample_distance,(Uint16 *)&bufr[73]); - mdc_hostftovaxf(header->isotope_halflife,(Uint16 *)&bufr[83]); - bufr[85] = header->frame_duration_sec; - mdc_hostltovaxl(header->gate_duration,(Uint16 *)&bufr[86]); - mdc_hostltovaxl(header->r_wave_offset,(Uint16 *)&bufr[88]); - mdc_hostftovaxf(header->scale_factor,(Uint16 *)&bufr[91]); - bufr[96] = header->scan_min; - bufr[97] = header->scan_max; - mdc_hostltovaxl(header->prompts,(Uint16 *)&bufr[98]); - mdc_hostltovaxl(header->delayed,(Uint16 *)&bufr[100]); - mdc_hostltovaxl(header->multiples,(Uint16 *)&bufr[102]); - mdc_hostltovaxl(header->net_trues,(Uint16 *)&bufr[104]); - for (i=0; i<16; i++) - { - mdc_hostftovaxf(header->cor_singles[i],(Uint16 *)&bufr[158+2*i]); - mdc_hostftovaxf(header->uncor_singles[i],(Uint16 *)&bufr[190+2*i]); - }; - mdc_hostftovaxf(header->tot_avg_cor,(Uint16 *)&bufr[222]); - mdc_hostftovaxf(header->tot_avg_uncor,(Uint16 *)&bufr[224]); - mdc_hostltovaxl(header->total_coin_rate,(Uint16 *)&bufr[226]); - /* total coin rate */ - mdc_hostltovaxl(header->frame_start_time,(Uint16 *)&bufr[228]); - mdc_hostltovaxl(header->frame_duration,(Uint16 *)&bufr[230]); - mdc_hostftovaxf(header->loss_correction_fctr,(Uint16 *)&bufr[232]); - for (i=0; i<8; i++) - mdc_hostltovaxl(header->phy_planes[i],(Uint16 *)&bufr[234+2*i]); - - - if (MdcHostBig()) - MdcSWAB( (Uint8 *)bufr, (Uint8 *)bufr, MdcMatBLKSIZE); - - err = mdc_mat_wblk( fptr, blknum, (Uint8 *)bufr, 1); - return (err); -} - -Int32 mdc_mat_write_attn_subheader( fptr, blknum, header) - FILE *fptr; - Int32 blknum; - Mdc_Attn_subheader *header; -{ - Int16 bufr[256]; - Int32 i,err; - - for (i=0; i<256; bufr[i++]=0); - bufr[0] = 256; - bufr[1] = 1; - bufr[2] = 22; - bufr[3] = -1; - bufr[4] = 25; - bufr[5] = 62; - bufr[6] = 79; - bufr[7] = 106; - bufr[24] = 37; - bufr[25] = -1; - bufr[61] = 17; - bufr[62] = -1; - bufr[78] = 27; - bufr[79] = -1; - bufr[105] = 52; - bufr[106] = -1; - bufr[63] = header->data_type; - bufr[64] = header->attenuation_type; - bufr[66] = header->dimension_1; - bufr[67] = header->dimension_2; - mdc_hostftovaxf( header->scale_factor,(Uint16 *)&bufr[91]); - mdc_hostftovaxf( header->x_origin,(Uint16 *)&bufr[93]); - mdc_hostftovaxf( header->y_origin,(Uint16 *)&bufr[95]); - mdc_hostftovaxf( header->x_radius,(Uint16 *)&bufr[97]); - mdc_hostftovaxf( header->y_radius,(Uint16 *)&bufr[99]); - mdc_hostftovaxf( header->tilt_angle,(Uint16 *)&bufr[101]); - mdc_hostftovaxf( header->attenuation_coeff,(Uint16 *)&bufr[103]); - mdc_hostftovaxf( header->sample_distance,(Uint16 *)&bufr[105]); - if (MdcHostBig()) - MdcSWAB( (Uint8 *)bufr, (Uint8 *)bufr, 512); - err = mdc_mat_wblk( fptr, blknum, (Uint8 *)bufr, 1); - return (err); -} - -Int32 mdc_mat_write_norm_subheader( fptr, blknum, header) - FILE *fptr; - Int32 blknum; - Mdc_Norm_subheader *header; -{ - Int16 bufr[256]; - Int32 i,err; - - for (i=0; i<256; bufr[i++]=0); - bufr[0] = 256; - bufr[1] = 1; - bufr[2] = 22; - bufr[3] = -1; - bufr[4] = 25; - bufr[5] = 62; - bufr[6] = 79; - bufr[7] = 106; - bufr[24] = 37; - bufr[25] = -1; - bufr[61] = 17; - bufr[62] = -1; - bufr[78] = 27; - bufr[79] = -1; - bufr[105] = 52; - bufr[106] = -1; - bufr[63] = header->data_type; - bufr[66] = header->dimension_1; - bufr[67] = header->dimension_2; - mdc_hostftovaxf( header->scale_factor,(Uint16 *)&bufr[91]); - bufr[93] = header->norm_hour; - bufr[94] = header->norm_minute; - bufr[95] = header->norm_second; - bufr[96] = header->norm_day; - bufr[97] = header->norm_month; - bufr[98] = header->norm_year; - mdc_hostftovaxf( header->fov_source_width,(Uint16 *)&bufr[99]); - mdc_hostftovaxf( header->ecat_calib_factor,(Uint16 *)&bufr[101]); - if (MdcHostBig()) - MdcSWAB( (Uint8 *)bufr, (Uint8 *)bufr, 512); - err = mdc_mat_wblk( fptr, blknum, (Uint8 *)bufr, 1); - return (err); -} - -Int32 mdc_mat_read_attn_subheader( fptr, blknum, header) -FILE *fptr; -Int32 blknum; -Mdc_Attn_subheader *header; -{ - Int16 bufr[256]; - Int32 err; - - err = mdc_mat_rblk( fptr, blknum, (Uint8 *)bufr, 1); - if (err) return(err); - if (MdcHostBig()) - MdcSWAB( (Uint8 *)bufr, (Uint8 *)bufr, MdcMatBLKSIZE); - - header->data_type = bufr[63]; - header->attenuation_type = bufr[64]; - header->dimension_1 = bufr[66]; - header->dimension_2 = bufr[67]; - header->scale_factor = mdc_get_vax_float((Uint16 *)bufr, 91); - header->x_origin = mdc_get_vax_float((Uint16 *)bufr, 93); - header->y_origin = mdc_get_vax_float((Uint16 *)bufr, 95); - header->x_radius = mdc_get_vax_float((Uint16 *)bufr, 97); - header->y_radius = mdc_get_vax_float((Uint16 *)bufr, 99); - header->tilt_angle = mdc_get_vax_float((Uint16 *)bufr, 101); - header->attenuation_coeff = mdc_get_vax_float((Uint16 *)bufr, 103); - header->sample_distance = mdc_get_vax_float((Uint16 *)bufr, 105); - return (0); -} - -Int32 mdc_mat_read_attn_subheader7( fptr, blknum, h) -FILE *fptr; -Int32 blknum; -Mdc_Attn_subheader7 *h; -{ - Int16 b[256]; - Int32 err, i; - char *bb; - - err = mdc_mat_rblk( fptr, blknum, (Uint8 *)b, 1); - if (err) return(err); - bb = (char *)b; - - memcpy(&h->data_type ,bb , 2); MdcSWAP(h->data_type); - memcpy(&h->num_dimensions ,bb+ 2, 2); MdcSWAP(h->num_dimensions); - memcpy(&h->attenuation_type ,bb+ 4, 2); MdcSWAP(h->attenuation_type); - memcpy(&h->num_r_elements ,bb+ 6, 2); MdcSWAP(h->num_r_elements); - memcpy(&h->num_angles ,bb+ 8, 2); MdcSWAP(h->num_angles); - memcpy(&h->num_z_elements ,bb+ 10, 2); MdcSWAP(h->num_z_elements); - memcpy(&h->ring_difference ,bb+ 12, 2); MdcSWAP(h->ring_difference); - memcpy(&h->x_resolution ,bb+ 14, 4); MdcSWAP(h->x_resolution); - memcpy(&h->y_resolution ,bb+ 18, 4); MdcSWAP(h->y_resolution); - memcpy(&h->z_resolution ,bb+ 22, 4); MdcSWAP(h->z_resolution); - memcpy(&h->w_resolution ,bb+ 26, 4); MdcSWAP(h->w_resolution); - memcpy(&h->scale_factor ,bb+ 30, 4); MdcSWAP(h->scale_factor); - memcpy(&h->x_offset ,bb+ 34, 4); MdcSWAP(h->x_offset); - memcpy(&h->y_offset ,bb+ 38, 4); MdcSWAP(h->y_offset); - memcpy(&h->x_radius ,bb+ 42, 4); MdcSWAP(h->x_radius); - memcpy(&h->y_radius ,bb+ 46, 4); MdcSWAP(h->y_radius); - memcpy(&h->tilt_angle ,bb+ 50, 4); MdcSWAP(h->tilt_angle); - memcpy(&h->attenuation_coeff ,bb+ 54, 4); MdcSWAP(h->attenuation_coeff); - memcpy(&h->attenuation_min ,bb+ 58, 4); MdcSWAP(h->attenuation_min); - memcpy(&h->attenuation_max ,bb+ 62, 4); MdcSWAP(h->attenuation_max); - memcpy(&h->skull_thickness ,bb+ 66, 4); MdcSWAP(h->skull_thickness); - memcpy(&h->num_xtra_atten_coeff ,bb+ 70, 2); - MdcSWAP(h->num_xtra_atten_coeff); - memcpy(&h->xtra_atten_coeff ,bb+ 72, 32); - for (i=0; i<8; i++) MdcSWAP(h->xtra_atten_coeff[i]); - memcpy(&h->edge_finding_threshold,bb+104, 4); - MdcSWAP(h->edge_finding_threshold); - memcpy(&h->storage_order ,bb+108, 2); MdcSWAP(h->storage_order); - memcpy(&h->span ,bb+110, 2); MdcSWAP(h->span); - memcpy(&h->z_elements ,bb+112,128); - for (i=0; i<64; i++) MdcSWAP(h->z_elements[i]); - memcpy(&h->fill_unused ,bb+240,172); - for (i=0; i<86; i++) MdcSWAP(h->fill_unused[i]); - memcpy(&h->fill_user ,bb+412,100); - for (i=0; i<50; i++) MdcSWAP(h->fill_user[i]); - - return (0); -} - - Int32 mdc_mat_read_norm_subheader( fptr, blknum, header) - FILE *fptr; Int32 blknum; Mdc_Norm_subheader *header; -{ - Int16 bufr[256]; - Int32 err; - - err = mdc_mat_rblk( fptr, blknum, (Uint8 *)bufr, 1); - if (err) return(err); - if (MdcHostBig()) - MdcSWAB( (Uint8 *)bufr, (Uint8 *)bufr, MdcMatBLKSIZE); - - header->data_type = bufr[63]; - header->dimension_1 = bufr[66]; - header->dimension_2 = bufr[67]; - header->scale_factor = mdc_get_vax_float((Uint16 *)bufr, 91); - header->norm_hour = bufr[93]; - header->norm_minute = bufr[94]; - header->norm_second = bufr[95]; - header->norm_day = bufr[96]; - header->norm_month = bufr[97]; - header->norm_year = bufr[98]; - header->fov_source_width = mdc_get_vax_float((Uint16 *)bufr, 99); - header->ecat_calib_factor = mdc_get_vax_float((Uint16 *)bufr, 101); - return (0); -} - -/* Following function was copied from CTI-source file 'matrix_extra.c' */ -/* and slightly modified ... */ - -Int32 mdc_write_matrix_data(fptr, strtblk, nblks, dptr, dtype) -FILE *fptr; -Int32 strtblk, - nblks, - dtype; -Uint8 *dptr; -{ - Int32 err; - - switch (dtype) - { - case 1: /* byte format...no - * translation necessary */ - err = mdc_mat_wblk(fptr, strtblk, dptr, nblks); - break; - case 2: /* Vax I*2 */ - err = mdc_mat_write_idata(fptr, strtblk, (Uint8 *)dptr, 512 * nblks); - break; - case 4: /* Vax R*4 */ - err = mdc_mat_write_fdata(fptr, strtblk, (float *)dptr, 512 * nblks); - break; - case 5: /* IEEE R*4 */ - err = mdc_mat_wblk(fptr, strtblk, dptr, nblks); - break; - case 6: /* 68K I*2 */ - err = mdc_mat_wblk(fptr, strtblk, dptr, nblks); - break; - case 7: /* 68K I*4 */ - err = mdc_mat_wblk(fptr, strtblk, dptr, nblks); - break; - default: /* something - * else...treat as Vax - * I*2 */ - err = mdc_mat_write_idata(fptr, strtblk, (Uint8 *)dptr, 512 * nblks); - break; - } - - return (err); -} - -/* code from mat_get_spec.c */ -Int32 mdc_mat_get_spec (char *file, Int32 *num_frames, Int32 *num_planes, Int32 *num_gates, Int32 *num_bed) -{ - struct Mdc_MatDir matrixlist[5000]; - FILE *fptr; - Int32 status, num_matrices, i; - struct Mdc_Matval matnum; - - /* initialization */ - status = 0; - *num_frames = 0; - *num_planes = 0; - *num_gates = 0; - *num_bed = 0; - - /* open the specified file */ - fptr = mdc_mat_open (file, "r"); - if (fptr != NULL) - { - /* get the matrix entries */ - num_matrices = mdc_mat_list( fptr, matrixlist, 5000); - - for (i=0; i *num_frames) - (*num_frames)++; - - if (matnum.plane > *num_planes) - (*num_planes)++; - - if (matnum.gate > *num_gates) - (*num_gates)++; - - if (matnum.bed > *num_bed) - (*num_bed)++; - } - - /* bed is zero based in the matrix number, but all numbers returned */ - /* from this function will be one based */ - (*num_bed)++; - mdc_mat_close (fptr); - } - else - status = 1; - - return(status); -} - -/* code from sort_order.c */ - -static int mdc_compare_anatloc(const void *vi, const void *vj) -{ - struct ExpMatDir *i, *j; - - i = (struct ExpMatDir *)vi; - j = (struct ExpMatDir *)vj; - - if (i->anatloc < j->anatloc) return (-1); - if (i->anatloc > j->anatloc) return (1); - return (0); -} - -/* matrix list by anatomical position */ -void mdc_anatomical_sort (struct Mdc_MatDir matrix_list[], Int32 num_matrices, Mdc_Main_header *mhead, Int32 num_bed_pos) -{ - struct Mdc_Matval matval; - Int32 i, plane, bed; - float bed_pos[16], plane_separation; - struct ExpMatDir exp_matlist[5000]; - - bed_pos[0] = 0.0; - for (i=1; i < num_bed_pos; i++) - bed_pos[i] = mhead->bed_offset[i-1]; - - plane_separation = mhead->plane_separation; - -/* if plane separation not filled in main header, use plane number to sort */ - if (plane_separation == 0.0) plane_separation = 1.0; - - for (i=0; i < num_matrices; i++) - { - mdc_mat_numdoc (matrix_list[i].matnum, &matval); - plane = matval.plane; - bed = matval.bed; - exp_matlist[i].matnum = matrix_list[i].matnum; - exp_matlist[i].strtblk = matrix_list[i].strtblk; - exp_matlist[i].endblk = matrix_list[i].endblk; - exp_matlist[i].matstat = matrix_list[i].matstat; - exp_matlist[i].anatloc = bed_pos[bed]+(plane-1)*plane_separation; - } - - qsort(exp_matlist,(unsigned)num_matrices - ,sizeof(struct ExpMatDir) - ,mdc_compare_anatloc); - - for (i=0; i < num_matrices; i++) - { - matrix_list[i].matnum = exp_matlist[i].matnum; - matrix_list[i].strtblk = exp_matlist[i].strtblk; - matrix_list[i].endblk = exp_matlist[i].endblk; - matrix_list[i].matstat = exp_matlist[i].matstat; - } -} - -static int mdc_compmatdir(const void *vi, const void *vj) -{ - struct Mdc_MatDir *i, *j; - - i = (struct Mdc_MatDir *)vi; - j = (struct Mdc_MatDir *)vj; - - return((i->matnum - j->matnum)); -} - - -void mdc_matnum_sort(struct Mdc_MatDir mlist[], Int32 num_entry) -{ - qsort(mlist,(unsigned)num_entry, sizeof(struct Mdc_MatDir), mdc_compmatdir); -} - -/* sort by planes varying first */ -void mdc_plane_sort (struct Mdc_MatDir matrix_list[], Int32 num_matrices) -{ - struct Mdc_Matval matval; - Int32 i, frame, plane, bed; - struct ExpMatDir exp_matlist[5000]; - - for (i=0; i < num_matrices; i++) - { - mdc_mat_numdoc (matrix_list[i].matnum, &matval); - plane = matval.plane; - frame = matval.frame; - bed = matval.bed; - exp_matlist[i].matnum = matrix_list[i].matnum; - exp_matlist[i].strtblk = matrix_list[i].strtblk; - exp_matlist[i].endblk = matrix_list[i].endblk; - exp_matlist[i].matstat = matrix_list[i].matstat; - exp_matlist[i].anatloc = (float)(frame*1000 + plane*10 + bed); - } - - qsort (exp_matlist,(unsigned)num_matrices - ,sizeof(struct ExpMatDir) - ,mdc_compare_anatloc); - - for (i=0; i < num_matrices; i++) - { - matrix_list[i].matnum = exp_matlist[i].matnum; - matrix_list[i].strtblk = exp_matlist[i].strtblk; - matrix_list[i].endblk = exp_matlist[i].endblk; - matrix_list[i].matstat = exp_matlist[i].matstat; - } - -} --- a/source/m-matrix.h +++ b/source/m-matrix.h @@ -7,620 +7,13 @@ * * * project : (X)MedCon by Erik Nolf * * * - * Notes : Source code addapted from CTI PET Systems, Inc. * - * Original code 2.2 10/19/93 Copyright 1989-1993 * - * * - * Changed code for swapping & the use of my data types * - * with machine independency as purpose * - * * - * Added structs and prototypes for ECAT 7 reading support * + * Notes : DEBIAN - code removed due to licensing issues * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* $Id: m-matrix.h,v 1.25 2013/06/23 21:51:19 enlf Exp $ +/* - debian dummy file v0.1 - */ -/* - Copyright (C) 1997-2013 by Erik Nolf - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any later - version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General - Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 59 Place - Suite 330, Boston, MA 02111-1307, USA. */ - #ifndef __M_MATRIX_H__ #define __M_MATRIX_H__ - -/**************************************************************************** - D E F I N E S -****************************************************************************/ - -#define MDC_ECAT6_MAX_MATRICES 5000 - -#define MdcMatBLKSIZE 512 -#define MdcMatFirstDirBlk 2 - -#define MdcMatrixBlocks(x) (((x+(MdcMatBLKSIZE-1))/MdcMatBLKSIZE)*MdcMatBLKSIZE); - -struct Mdc_MatDir { - Int32 matnum; - Int32 strtblk; - Int32 endblk; - Int32 matstat; -}; - -typedef struct mdc_matdir { - Int32 nmats; - Int32 nmax; - struct Mdc_MatDir *entry; -} *Mdc_Mat_dir; - -struct Mdc_Matval { - Int32 frame, plane, gate, data, bed; -}; - -/* -#define TotalCounts 0 -#define UnknownCalib TotalCounts + 1 -#define MDC_ECAT_COUNTS UnknownCalib + 1 -#define MCi_ML MDC_ECAT_COUNTS + 1 -#define LmrGlu MCi_ML + 1 -#define LmrGlu_mMole LmrGlu + 1 -#define LmrGlu_mGram LmrGlu_mMole + 1 -#define NCi_ML LmrGlu_mGram + 1 -#define WELL_COUNTS NCi_ML + 1 -#define BECQUERELS WELL_COUNTS + 1 -*/ - -typedef struct mdc_mat_main_header { - char original_file_name[20]; - Int16 sw_version; - Int16 data_type; - Int16 system_type; - Int16 file_type; - char node_id[10]; - Int16 scan_start_day, - scan_start_month, - scan_start_year, - scan_start_hour, - scan_start_minute, - scan_start_second; - char isotope_code[8]; - float isotope_halflife; - char radiopharmaceutical[32]; - float gantry_tilt, - gantry_rotation, - bed_elevation; - Int16 rot_source_speed, - wobble_speed, - transm_source_type; - float axial_fov, - transaxial_fov; - Int16 transaxial_samp_mode, - coin_samp_mode, - axial_samp_mode; - float calibration_factor; - Int16 calibration_units, - compression_code; - char study_name[12], - patient_id[16], - patient_name[32], - patient_sex, - patient_age[10], - patient_height[10], - patient_weight[10], - patient_dexterity, - physician_name[32], - operator_name[32], - study_description[32]; - Int16 acquisition_type, - bed_type, - septa_type; - char facility_name[20]; - Int16 num_planes, - num_frames, - num_gates, - num_bed_pos; - float init_bed_position, - bed_offset[15], - plane_separation; - Int16 lwr_sctr_thres, - lwr_true_thres, - upr_true_thres; - float collimator; - char user_process_code[10]; - Int16 acquisition_mode; - -} Mdc_Main_header; - -#define MH_64_SIZE 446 - -typedef struct mdc_mat_main_header7 { - - char magic_number[14]; - char original_file_name[32]; - Int16 sw_version; - Int16 system_type; - Int16 file_type; - char serial_number[10]; - Uint32 scan_start_time; - char isotope_name[8]; - float isotope_halflife; - char radiopharmaceutical[32]; - float gantry_tilt; - float gantry_rotation; - float bed_elevation; - float intrinsic_tilt; - Int16 wobble_speed; - Int16 transm_source_type; - float distance_scanned; - float transaxial_fov; - Int16 angular_compression; - Int16 coin_samp_mode; - Int16 axial_samp_mode; - float ecat_calibration_factor; - Int16 calibration_units; - Int16 calibration_units_label; - Int16 compression_code; - char study_type[12]; - char patient_id[16]; - char patient_name[32]; - char patient_sex[1]; - char patient_dexterity[1]; - float patient_age; - float patient_height; - float patient_weight; - Uint32 patient_birth_date; - char physician_name[32]; - char operator_name[32]; - char study_description[32]; - Int16 acquisition_type; - Int16 patient_orientation; - char facility_name[20]; - Int16 num_planes; - Int16 num_frames; - Int16 num_gates; - Int16 num_bed_pos; - float init_bed_position; - float bed_position[15]; - float plane_separation; - Int16 lwr_sctr_thres; - Int16 lwr_true_thres; - Int16 upr_true_thres; - char user_process_code[10]; - Int16 acquisition_mode; - float bin_size; - float branching_fraction; - Uint32 dose_start_time; - float dosage; - float well_counter_corr_factor; - char data_units[32]; - Int16 septa_state; - Int16 fill_cti[6]; - -} Mdc_Main_header7; - -#define MH_72_SIZE 512 - -typedef struct mdc_mat_scan_subheader { - Int16 data_type, - dimension_1, - dimension_2, - smoothing, - processing_code; - float sample_distance, - isotope_halflife; - Int16 frame_duration_sec; - Int32 gate_duration, - r_wave_offset; - float scale_factor; - Int16 scan_min, - scan_max; - Int32 prompts, - delayed, - multiples, - net_trues; - float cor_singles[16], - uncor_singles[16], - tot_avg_cor, - tot_avg_uncor; - Int32 total_coin_rate, - frame_start_time, - frame_duration; - float loss_correction_fctr; - Int32 phy_planes[8]; - -} Mdc_Scan_subheader; - -#define SSH_64_SIZE 236 - -typedef struct mdc_mat_scan_subheader7 { - - Int16 data_type; - Int16 num_dimensions; - Int16 num_r_elements; - Int16 num_angles; - Int16 corrections_applied; - Int16 num_z_elements; - Int16 ring_difference; - float x_resolution; - float y_resolution; - float z_resolution; - float w_resolution; - Int16 fill[6]; - Uint32 gate_duration; - Int32 r_wave_offset; - Int32 num_accepted_beats; - float scale_factor; - Int16 scan_min; - Int16 scan_max; - Int32 prompts; - Int32 delayed; - Int32 multiples; - Int32 net_trues; - float cor_singles[16]; - float uncor_singles[16]; - float tot_avg_cor; - float tot_avg_uncor; - Int32 total_coin_rate; - Uint32 frame_start_time; - Uint32 frame_duration; - float deadtime_correction_factor; - Int16 phy_planes[8]; - Int16 cti_fill[83]; - Int16 user_fill[50]; - -} Mdc_Scan_subheader7; - -#define SSH_72_SIZE 234 - -typedef struct mdc_mat_image_subheader { - Int16 data_type, - num_dimensions, - dimension_1, - dimension_2; - float x_origin, - y_origin, - recon_scale, /* Image ZOOM from reconstruction */ - quant_scale; /* Scale Factor */ - Int16 image_min, - image_max; - float pixel_size, - slice_width; - Int32 frame_duration, - frame_start_time; - Int16 slice_location, - recon_start_hour, - recon_start_minute, - recon_start_sec; - Int32 gate_duration; - Int16 filter_code; - Int32 scan_matrix_num, - norm_matrix_num, - atten_cor_matrix_num; - float image_rotation, - plane_eff_corr_fctr, - decay_corr_fctr, - loss_corr_fctr, - intrinsic_tilt ; - Int16 processing_code, - quant_units, - recon_start_day, - recon_start_month, - recon_start_year; - float ecat_calibration_fctr, - well_counter_cal_fctr, - filter_params[6]; - char annotation[40]; - -} Mdc_Image_subheader; - -#define ISH_64_SIZE 172 - -typedef struct mdc_mat_image_subheader7 { - - Int16 data_type; - Int16 num_dimensions; - Int16 x_dimension; - Int16 y_dimension; - Int16 z_dimension; - float x_offset; - float y_offset; - float z_offset; - float recon_zoom; - float scale_factor; - Int16 image_min; - Int16 image_max; - float x_pixel_size; - float y_pixel_size; - float z_pixel_size; - Uint32 frame_duration; - Uint32 frame_start_time; - Int16 filter_code; - float x_resolution; - float y_resolution; - float z_resolution; - float num_r_elements; - float num_angles; - float z_rotation_angle; - float decay_corr_fctr; - Int32 processing_code; - Uint32 gate_duration; - Int32 r_wave_offset; - Int32 num_accepted_beats; - float filter_cutoff_frequency; - float filter_resolution; - float filter_ramp_slope; - Int16 filter_order; - float filter_scatter_fraction; - float filter_scatter_slope; - char annotation[40]; - float mt_1_1; - float mt_1_2; - float mt_1_3; - float mt_2_1; - float mt_2_2; - float mt_2_3; - float mt_3_1; - float mt_3_2; - float mt_3_3; - float rfilter_cutoff; - float rfilter_resolution; - Int16 rfilter_code; - Int16 rfilter_order; - float zfilter_cutoff; - float zfilter_resolution; - Int16 zfilter_code; - Int16 zfilter_order; - float mt_1_4; - float mt_2_4; - float mt_3_4; - Int16 scatter_type; - Int16 recon_type; - Int16 recon_views; - Int16 fill_cti[87]; - Int16 fill_user[48]; - -} Mdc_Image_subheader7; - -#define ISH_72_SIZE 510 - -typedef struct mdc_mat_norm_subheader { - Int16 data_type, - dimension_1, - dimension_2; - float scale_factor; - Int16 norm_hour, - norm_minute, - norm_second, - norm_day, - norm_month, - norm_year; - float fov_source_width; - float ecat_calib_factor; - -} Mdc_Norm_subheader; - -#define NSH_64_SIZE 30 - -typedef struct mdc_mat_norm_subheader7 { - - Int16 data_type; - Int16 num_dimensions; - Int16 num_r_elements; - Int16 num_angles; - Int16 num_z_elements; - Int16 ring_difference; - float scale_factor; - float norm_min; - float norm_max; - float fov_source_width; - float norm_quality_factor; - Int16 norm_quality_factor_code; - Int16 storage_order; - Int16 span; - Int16 z_elements[64]; - Int16 cti_fill[123]; - Int16 user_fill[50]; - -} Mdc_Norm_subheader7; - -#define NSH_72_SIZE 166 - -typedef struct mdc_mat_attn_subheader { - Int16 data_type, - attenuation_type, - dimension_1, - dimension_2; - float scale_factor, - x_origin, - y_origin, - x_radius, - y_radius, - tilt_angle, - attenuation_coeff, - sample_distance; - -} Mdc_Attn_subheader; - -#define ASH_64_SIZE 40 - -typedef struct mdc_mat_attn_subheader7 { - - Int16 data_type; - Int16 num_dimensions; - Int16 attenuation_type; - Int16 num_r_elements; - Int16 num_angles; - Int16 num_z_elements; - Int16 ring_difference; - float x_resolution; - float y_resolution; - float z_resolution; - float w_resolution; - float scale_factor; - float x_offset; - float y_offset; - float x_radius; - float y_radius; - float tilt_angle; - float attenuation_coeff; - float attenuation_min; - float attenuation_max; - float skull_thickness; - Int16 num_xtra_atten_coeff; - float xtra_atten_coeff[8]; - float edge_finding_threshold; - Int16 storage_order; - Int16 span; - Int16 z_elements[64]; - Int16 fill_unused[86]; - Int16 fill_user[50]; - -} Mdc_Attn_subheader7; - -#define ASH_72_SIZE 512 - -typedef struct mdc_matdirnode { - Int32 matnum; - Int32 strtblk; - Int32 endblk; - Int32 matstat; - struct mdc_matdirnode *next; -} Mdc_MatDirNode; - -typedef struct mdc_matdirlist { - Int32 nmats; - Mdc_MatDirNode *first; - Mdc_MatDirNode *last; -} Mdc_MatDirList; - -typedef struct mdc_matrixdata { - Int32 mat_type; - Int32 matnum; - Uint8 *shptr; - Uint8 *data_ptr; - Int32 nviews; - Int32 nelements; - Int32 nblks; - Int32 data_type; -} Mdc_MatrixData; - -typedef struct mdc_matrix_file { - Mdc_Main_header *mhptr; - Mdc_MatDirList *dirlist; - FILE *fptr; - Int32 mode; - char *fname[80]; -} Mdc_MatrixFile; - -typedef struct mdc_matdirblk { - Int32 nfree, nextblk, prvblk, nused; - struct Mdc_MatDir matdir[31]; -} Mdc_MatDirBlk; - -#define BYTE_TYPE 1 -#define VAX_I2 2 -#define VAX_I4 3 -#define VAX_R4 4 -#define IEEE_R4 5 -#define M68K_I2 6 -#define M68K_I4 7 -#define SUN_I2 M68K_I2 -#define SUN_I4 M68K_I4 -#define SUN_R4 IEEE_R4 - -#define RAW_DATA 1 -#define IMAGE_DATA 2 -#define ATTN_DATA 3 -#define NORM_DATA 4 -#define SUN_READ 1 -#define SUN_WRITE 2 -#define ACS_READ 3 -#define ACS_WRITE 4 -#define SUN_CREATE 5 - -#define ACQM_NORMAL 0 /* normal acquisition mode */ -#define ACQM_RODTRN 1 /* rod transmission mode */ -#define ACQM_RODTRN_KEEP 2 /* rod transmission mode keep all sinograms */ -#define ACQM_DWIN_KEEP 3 /* dual window mode keep all sinograms */ -#define ACQM_DWIN 4 /* dual window mode */ -#define ACQM_SIMULT 5 /* simultaneous transmission/ emission mode */ - -/* eNlf: BEGIN - unnecessary, avoid conflicts! */ -/* #define ERROR -1 */ -/* #define OK 0 */ -/* eNlf: END - unnecessary, avoid conflicts! */ - -/**************************************************************************** - F U N C T I O N S -****************************************************************************/ -Int32 MdcSWAW( Uint16 from[], Uint16 to[], Int32 length); -Int32 MdcSWAB( Uint8 from[], Uint8 to[], Int32 length); -FILE *mdc_mat_open(char *fname, char *fmode); -void mdc_mat_close(FILE *fptr); -Int32 mdc_mat_rblk(FILE *fptr, Int32 blkno, Uint8 *bufr, Int32 nblks); -Int32 mdc_mat_list(FILE *fptr, struct Mdc_MatDir mlist[], Int32 lmax); -Int32 mdc_mat_list7(FILE *fptr, struct Mdc_MatDir mlist[], Int32 lmax); -Int32 mdc_mat_numcod(Int32 frame, Int32 plane, Int32 gate, Int32 data, Int32 bed); -Int32 mdc_mat_numdoc( Int32 mdc_matnum, struct Mdc_Matval *matval); -Int32 mdc_mat_lookup(FILE *fptr, Int32 matnum, struct Mdc_MatDir *entry); -Int32 mdc_mat_lookup7(FILE *fptr, Int32 matnum, struct Mdc_MatDir *entry); -Int32 mdc_mat_read_main_header(FILE *fptr, Mdc_Main_header *h); -Int32 mdc_mat_read_main_header7(FILE *fptr, Mdc_Main_header7 *h); -Int32 mdc_mat_read_matrix_data(FILE *fptr, Int32 blk, Int32 nblks, Int16 bufr[]); -Int32 mdc_mat_read_mat_data(FILE *fptr, Int32 strtblk, Int32 nblks, Uint8 *dptr, Int32 dtype); -Int32 mdc_mat_read_mat_data7(FILE *fptr, Int32 strtblk, Int32 nblks, Uint8 *dptr, Int32 dtype); -Int32 mdc_mat_read_scan_subheader(FILE *fptr, Int32 blknum, Mdc_Scan_subheader *h); -Int32 mdc_mat_read_scan_subheader7(FILE *fptr, Int32 blknum, Mdc_Scan_subheader7 *h); -Int32 mdc_mat_read_image_subheader(FILE *fptr, Int32 blknum, Mdc_Image_subheader *h); -Int32 mdc_mat_read_image_subheader7(FILE *fptr, Int32 blknum, Mdc_Image_subheader7 *h); -float mdc_get_vax_float(Uint16 bufr[], Int32 off); -Int32 mdc_get_vax_long(Uint16 bufr[], Int32 off); -Mdc_Mat_dir mdc_mat_read_dir(FILE *fptr, Uint8 *selector); -Int32 mdc_mat_wblk(FILE *fptr, Int32 blkno, Uint8 *bufr, Int32 nblks); -FILE *mdc_mat_create(char *fname, Mdc_Main_header *mhead); -Int32 mdc_mat_enter(FILE *fptr, Int32 matnum, Int32 nblks); -Int32 mdc_mat_write_image(FILE *fptr, Int32 matnum, Mdc_Image_subheader *header, Uint16 *data, Int32 data_size); -Int32 mdc_mat_write_scan(FILE *fptr, Int32 matnum, Mdc_Scan_subheader *header, Uint16 *data, Int32 data_size); -Int32 mdc_mat_write_attn(FILE *fptr, Int32 matnum, Mdc_Attn_subheader *header, float *data, Int32 data_size); -Int32 mdc_mat_write_norm(FILE *fptr, Int32 matnum, Mdc_Norm_subheader *header, float *data, Int32 data_size); -Int32 mdc_mat_write_idata(FILE *fptr, Int32 blk, Uint8 *data, Int32 size); -Int32 mdc_mat_write_fdata(FILE *fptr, Int32 blk, float *data, Int32 size); -Int32 mdc_matrix_selector(Int32 matnum, Int32 ranges[2][5]); -Int32 mdc_decode_selector(char *s1, Int32 ranges[2][5]); -Int32 mdc_str_find(char *s1, char *s2); -Int32 mdc_str_replace(char *s1, char *s2, char *s3, char *s4); -Int32 mdc_string_replace(char *s1, char *s2, char *s3, char *s4); -Int32 mdc_fix_selector(char *s1, char *s2); -char* mdc_nex_word(char *s, char *w); -Int32 mdc_hostftovaxf(float f_orig, Uint16 number[]); -Int32 mdc_mat_write_main_header(FILE *fptr, Mdc_Main_header *header); -Int32 mdc_mat_write_image_subheader(FILE *fptr, Int32 blknum, Mdc_Image_subheader *header); -Int32 mdc_hostltovaxl(Int32 in, Uint16 out[2]); -Int32 mdc_mat_write_scan_subheader(FILE *fptr, Int32 blknum, Mdc_Scan_subheader *header); -Int32 mdc_mat_write_attn_subheader(FILE *fptr, Int32 blknum, Mdc_Attn_subheader *header); -Int32 mdc_mat_write_norm_subheader(FILE *fptr, Int32 blknum, Mdc_Norm_subheader *header); -Int32 mdc_mat_read_attn_subheader(FILE *fptr, Int32 blknum, Mdc_Attn_subheader *header); -Int32 mdc_mat_read_attn_subheader7(FILE *fptr, Int32 blknum, Mdc_Attn_subheader7 *h); -Int32 mdc_mat_read_norm_subheader(FILE *fptr, Int32 blknum, Mdc_Norm_subheader *header); -Int32 mdc_mat_read_norm_subheader7(FILE *fptr, Int32 blknum, Mdc_Norm_subheader7 *header); -Int32 mdc_write_matrix_data(FILE *fptr, Int32 strtblk, Int32 nblks, Uint8 *dptr, Int32 dtype); -double mdc_mat_qs(double *X, double *Z, Int32 lod); -double mdc_mat_max(double *X, Int32 lod); -double mdc_mat_min(double *X, Int32 lod); -Int32 mdc_mat_get_spec (char *file, Int32 *num_frames, Int32 *num_planes, Int32 *num_gates, Int32 *num_bed); -void mdc_anatomical_sort (struct Mdc_MatDir matrix_list[], Int32 num_matrices, Mdc_Main_header *mhead, Int32 num_bed_pos); -void mdc_matnum_sort(struct Mdc_MatDir mlist[], Int32 num_entry); -void mdc_plane_sort (struct Mdc_MatDir matrix_list[], Int32 num_matrices); - #endif debian/patches/add_gtk_libraries_to_linker.patch0000644000000000000000000000074112214301204017324 0ustar Author: Andreas Moog LastChanged: Sun, 18 Aug 2013 10:27:50 +0200 Description: Make sure gtk libraries are added to linker call --- a/source/Makefile.am +++ b/source/Makefile.am @@ -91,7 +91,7 @@ $(APPICON_OBJ): $(APPICON_OBJ:.o=.rc) xmedcon_LDADD = $(APPICON_OBJ) libmdc.la xmedcon_LDFLAGS = -mwindows $(GDK_PIXBUF_LIBS) -lm else -xmedcon_LDADD = libmdc.la +xmedcon_LDADD = libmdc.la $(XMEDCON_GTK_LIBS) xmedcon_LDFLAGS = $(GDK_PIXBUF_LIBS) -lm endif debian/patches/man-spelling.patch0000644000000000000000000007726012214301204014225 0ustar Author: Andreas Tille LastChanged: Tue, 23 Jul 2013 08:46:18 +0200 Description: Fix some lintian issues with manpages --- a/man/medcon.1 +++ b/man/medcon.1 @@ -7,7 +7,7 @@ medcon - MedCon conversion of medical im .in 0.2i .HP 7 .B medcon -[options] -f files ... +[options] \-f files ... .PP .br .SH DESCRIPTION @@ -47,7 +47,7 @@ NIfTI@Neuroimaging Informatics Technolog .PP .in 0.2i .TP -.B -f, --file, --files ... +.B \-f, \-\-file, \-\-files ... Read a list of files. .SH OPTIONS @@ -55,87 +55,87 @@ Read a list of files. .in 0.2i .TP -.B -8, --indexed-color -This color mode forces 24-bit RGB color images being reduced to an 8-bit indexed colormap. For color reduction in combination with dithering see the -dith option. +.B \-8, \-\-indexed\-color +This color mode forces 24\-bit RGB color images being reduced to an 8-bit indexed colormap. For color reduction in combination with dithering see the \-dith option. .TP -.B -24, --true-color -This color mode keeps a 24-bit image as is. +.B \-24, \-\-true\-color +This color mode keeps a 24\-bit image as is. .TP -.B -alias, --alias-naming +.B \-alias, \-\-alias\-naming Generate filenames based on patient and study information. The syntax of the resulting basename is: +++ and ++ -with the latter three id's applied in case the originating format is DICOM or Acr/Nema. See also -noprefix. Since Analyze does not have a patient_name, patient_id is used instead. +with the latter three id's applied in case the originating format is DICOM or Acr/Nema. See also \-noprefix. Since Analyze does not have a patient_name, patient_id is used instead. .TP -.B -anon, --anonymous +.B \-anon, \-\-anonymous Make patient and study related entries anonymous (filled with 'X'). This option -can not be used with option -ident. +can not be used with option \-ident. .TP -.B -b8, --unsigned-char +.B \-b8, \-\-unsigned\-char .TP -.B -b16, --signed-short +.B \-b16, \-\-signed\-short .TP -.B -b16.12 -Force writing of Uint8 or Int16 pixels. The special option -b16.12 only uses 12 bits, as unsigned however. With these options one can lose the quantified float values when the new format doesn't support a global rescale factor or slope/intercept. +.B \-b16.12 +Force writing of Uint8 or Int16 pixels. The special option \-b16.12 only uses 12 bits, as unsigned however. With these options one can lose the quantified float values when the new format doesn't support a global rescale factor or slope/intercept. .TP -.B -big, --big-endian +.B \-big, \-\-big\-endian Force writing of big endian files when supported by the format. .TP -.B -byframe, --sort-by-frame +.B \-byframe, \-\-sort\-by\-frame Set sort order in ECAT by frames, instead of the default anatomical sort (based on slice location). Identical planes in each frame will be grouped together. You don't want this. .TP -.B -c, --convert ... +.B \-c, \-\-convert ... Convert with a list of formats to convert to. Use the notation without quotes as specified in the above table. You can not use this option with -p. .TP -.B -contrast, --enable-contrast -Apply (DICOM) window centre/width contrast remapping. Although this may improve the display of images, any manufacturer independent pixel values (like HU, SUV) with quantitation options -qc or -qs will be lost. +.B \-contrast, \-\-enable\-contrast +Apply (DICOM) window centre/width contrast remapping. Although this may improve the display of images, any manufacturer independent pixel values (like HU, SUV) with quantitation options \-qc or \-qs will be lost. .TP -.B -cor, --coronal +.B \-cor, \-\-coronal Reslice the images of a volume into a coronal projection while preserving the real world dimensions. .TP -.B -crop=:::, --crop-images=::: -This option allows to crop an equal frame from all images at : where width and height are :. The upper-left corner of an image is at 0:0. +.B \-crop=:::, \-\-crop\-images=::: +This option allows one to crop an equal frame from all images at : where width and height are :. The upper\-left corner of an image is at 0:0. .TP -.B -cs, --cine-sorting -Apply cine sorting, 1st image of each time frame, 2nd image of each time frame, 3rd image of each time frame, ... (applicable on gated SPECT). Reapplying does NOT undo this sorting. For this you need option -cu. +.B \-cs, \-\-cine\-sorting +Apply cine sorting, 1st image of each time frame, 2nd image of each time frame, 3rd image of each time frame, ... (applicable on gated SPECT). Reapplying does NOT undo this sorting. For this you need option \-cu. .TP -.B -cu, --cine-undo -Undo the cine sorting (as a result of the option -cs). +.B \-cu, \-\-cine\-undo +Undo the cine sorting (as a result of the option \-cs). .TP -.B -cw=: -Remap contrast using specified centre/width pair. No spaces are allowed within this option. See also -contrast options. +.B \-cw=: +Remap contrast using specified centre/width pair. No spaces are allowed within this option. See also \-contrast options. .TP -.B -d, --debug +.B \-d, \-\-debug Show debug info. After reading a file, the program will display the contents of the internal FILEINFO structure. .TP -.B -db +.B \-db Only print main header of CTI ECAT files to standard output. .TP -.B -dith, --dither-color -Use dithering to improve quality of color reduction (from RGB to 8-bit indexed). +.B \-dith, \-\-dither\-color +Use dithering to improve quality of color reduction (from RGB to 8\-bit indexed). .TP -.B -e, --extract [image ranges ...] -A routine to extract images interactively, unless you specify normal style image ranges directly on the command-line separated by spaces. In normal style it is also possible to reorder the sequence of images. You need to specify an output conversion format (see option -c). Note that the extraction does NOT addapt the centre-centre slice separations. In other words, proper volume measurements could be lost. +.B \-e, \-\-extract [image ranges ...] +A routine to extract images interactively, unless you specify normal style image ranges directly on the command-line separated by spaces. In normal style it is also possible to reorder the sequence of images. You need to specify an output conversion format (see option \-c). Note that the extraction does NOT addapt the centre-centre slice separations. In other words, proper volume measurements could be lost. .PP .ti +1.2i Selection Type? 1=normal 2=ecat @@ -181,30 +181,30 @@ Give gates list? Give beds list? .TP -.B -ean, --echo-alias-name -A convenience function which quickly echoes the alias or human readable filename on screen, without any delay of image processing. For the syntax of this alias filename, see option -alias. The output could then be used in a script, for example to make interpretable links towards cryptic numbered files resulting from a DICOM series. +.B \-ean, \-\-echo\-alias\-name +A convenience function which quickly echoes the alias or human readable filename on screen, without any delay of image processing. For the syntax of this alias filename, see option \-alias. The output could then be used in a script, for example to make interpretable links towards cryptic numbered files resulting from a DICOM series. .TP -.B -fb-none, --without-fallback +.B \-fb\-none, \-\-without\-fallback .TP -.B -fb-anlz, --fallback-analyze +.B \-fb\-anlz, \-\-fallback\-analyze .TP -.B -fb-conc, --fallback-concorde +.B \-fb\-conc, \-\-fallback\-concorde .TP -.B -fb-dicom, --fallback-dicom +.B \-fb\-dicom, \-\-fallback\-dicom .TP -.B -fb-ecat, --fallback-ecat +.B \-fb\-ecat, \-\-fallback\-ecat Disable or specify a fallback read format in case autodetect failed. .TP -.B -fh, --flip-horizontal +.B \-fh, \-\-flip\-horizontal .TP -.B -fv, --flip-vertical -Flip images horizontal (-fh) along the X-axis, vertical (-fv) along the Y-axis respectively. Parameters such as slice orientation are NOT changed. See also the -rs option. +.B \-fv, \-\-flip\-vertical +Flip images horizontal (\-fh) along the X\-axis, vertical (\-fv) along the Y-axis respectively. Parameters such as slice orientation are NOT changed. See also the \-rs option. .TP -.B -fmosaic=xx, --force-mosaic=xx -Enforce the mosaic file support for DICOM or Acr/Nema formats. The *stamps* will be splitted into separate slices according to the values supplied on the command-line. See also extra options -interl and -mfixv. The preset arguments are: +.B \-fmosaic=xx, \-\-force\-mosaic=xx +Enforce the mosaic file support for DICOM or Acr/Nema formats. The *stamps* will be split into separate slices according to the values supplied on the command-line. See also extra options \-interl and \-mfixv. The preset arguments are: .PP .ti +1.2i = pixel width of image stamps (X) @@ -216,29 +216,29 @@ Enforce the mosaic file support for DICO = total number of image stamps (Z) .PP .ti +1.2i -.B medcon -f imagefile -fmosaic=64x64x30 +.B medcon \-f imagefile \-fmosaic=64x64x30 .TP -.B -g, --make-gray +.B \-g, \-\-make\-gray Remap coloured images to gray. This is necessary when you convert to formats which only support a grayscale colormap! .TP -.B -gap, --spacing-true-gap +.B \-gap, \-\-spacing\-true\-gap The spacing between slices is the true gap/overlap between adjacent slices. In contrary to the default behaviour where the spacing between slices is measured from the centre to centre of two adjacent slices (including gap/overlap). Applied in DICOM & Acr/Nema. .TP -.B -hackacr, --hack-acrtags +.B \-hackacr, \-\-hack\-acrtags Enables you to hack a file that contains Acr/Nema tags hidden somewhere. Some proprietary image formats do contain tags but are placed after some unknown headerinformation. This option will try to find some readable tags in the first 2048 bytes after which it will give some possible hints to get the images out of the file with the use of the interactive reading -procedure (see option `-i'). This experimental procedure can +procedure (see option `\-i'). This experimental procedure can fail badly ... .TP -.B -i, --interactive +.B \-i, \-\-interactive Selects the interactive reading procedure. Normally the program automatically detects the format or uses 'ecat' (or 'dicom') as default. With the interactive procedure it could be possible to read an uncompressed, unsupported format by answering the following questions: .PP @@ -266,15 +266,15 @@ Pixel data type? .ti +0.8i Redo input? .PP -The GUI allows to save such raw predef input (RPI) files, that can be used in a redirect statement: +The GUI allows one to save such raw predef input (RPI) files, that can be used in a redirect statement: .PP .in 1.0i -.B medcon -f unsupported.img -c intf -i < predef.rpi +.B medcon \-f unsupported.img \-c intf \-i < predef.rpi .PP Doing so you can create small scripts that will read and convert your unsupported images at once. .TP -.B -ident, --identify +.B \-ident, \-\-identify An interactive routine to specify the patient and study related information. This option can not be used with the option -anon. The questions asked are: @@ -294,60 +294,60 @@ Give study id/name/p-number? Give series description? .TP -.B -implicit, --write-implicit +.B \-implicit, \-\-write\-implicit Another DICOM related option to enforce the implicit VR little transfer syntax as output, instead of the default explicit transfer syntax. .TP -.B -interl, --mosaic-interlaced -An extra option used in combination with forced mosaic (-fmosaic). The option +.B \-interl, \-\-mosaic\-interlaced +An extra option used in combination with forced mosaic (\-fmosaic). The option indicates that the slices in the original mosaic are in fact interlaced. -See also options -fmosaic and -mfixv. +See also options \-fmosaic and \-mfixv. .TP -.B -little, --little-endian +.B \-little, \-\-little\-endian Force writing of little endian files when supported by the format. .TP -.B -lut, --load-lut +.B \-lut, \-\-load\-lut Load an external LUT color scheme. .TP -.B -mh, --map-hotmetal -Selects the hotmetal colormap. This is only usefull to GIF89a or PNG. +.B \-mh, \-\-map\-hotmetal +Selects the hotmetal colormap. This is only useful to GIF89a or PNG. .TP -.B -mr, --map-rainbow -Selects the rainbow colormap. This is only usefull to GIF89a or PNG. +.B \-mr, \-\-map\-rainbow +Selects the rainbow colormap. This is only useful to GIF89a or PNG. .TP -.B -mc, --map-combined -Selects the combined colormap. This is only usefull to GIF89a or PNG. +.B \-mc, \-\-map\-combined +Selects the combined colormap. This is only useful to GIF89a or PNG. .TP -.B -mi, --map-inverted -Selects the invers colormap. This is only usefull to GIF89a or PNG +.B \-mi, \-\-map\-inverted +Selects the invers colormap. This is only useful to GIF89a or PNG .TP -.B -mfixv, --mosaic-fix-voxel -Another extra option used in combination with forced mosaic (-fmosaic). Choosing +.B \-mfixv, \-\-mosaic\-fix\-voxel +Another extra option used in combination with forced mosaic (\-fmosaic). Choosing this options will rescale the real world voxel dimensions by the mosaic factor. -See also -fmosaic and -interl. +See also \-fmosaic and \-interl. .TP -.B -mosaic, --enable-mosaic -Enable mosaic file support in DICOM or Acr/Nema format. The *stamps* will be splitted into separate slices according to values found in the file. This autodetect routine will always fix the voxel sizes. To support other type of mosaic files, see option -fmosaic. +.B \-mosaic, \-\-enable\-mosaic +Enable mosaic file support in DICOM or Acr/Nema format. The *stamps* will be splitted into separate slices according to values found in the file. This autodetect routine will always fix the voxel sizes. To support other type of mosaic files, see option \-fmosaic. .TP -.B -n, --negatives +.B \-n, \-\-negatives Preserve negative values. When not selected, all negative -values are put to zero. In combination with quantitation (see -qs or -qc) +values are put to zero. In combination with quantitation (see \-qs or \-qc) the requested format must support pixels of type float, a global rescale factor or the more generic slope/intercept concept in order to preserve the (negative and positive) quantified values. .TP -.B -nf, --norm-over-frames +.B \-nf, \-\-norm\-over\-frames Normalize with minimum/maximum values found over images in a frame group (in case the original format has different frames). The default behaviour is normalization with minimum/maximum values found over all images. @@ -356,27 +356,27 @@ to a new pixeltype. The original pixel v to the new pixeltype boundaries based on the minimum/maximum values. .TP -.B -nometa, --write-without-meta +.B \-nometa, \-\-write\-without\-meta Write DICOM files without the part 10 meta header (group 0x0002). .TP -.B -nopath, --ignore-path +.B \-nopath, \-\-ignore\-path Ignore absolute path mentioned in the "name of data file" key of an interfile header. Do make sure then that the data file resides in the same directory as the header file. .TP -.B -noprefix, --without-prefix +.B \-noprefix, \-\-without\-prefix This option disables the numbered prefix in the output filename. In combination with the -alias option, one could create human readable and alphabetical sorted files from DICOM or Acr/Name multiple file volumes. .TP -.B -o, --output-name +.B \-o, \-\-output\-name Changes output filename for ALL files to be created. It is allowed to specify a full directory path as well. However, a full path disables unique filename prefixing. .TP -.B -one, --single-file +.B \-one, \-\-single\-file Write header and image to same file; as allowed for InterFile. .TP -.B -optgif, --options-gif +.B \-optgif, \-\-options-gif Define some GIF options when converting to the GIF format. Without this option a loop and background color are defined by default. This interactive routine asks the following questions: @@ -398,8 +398,8 @@ Background color? .in 0.2i .TP -.B -optspm, --options-spm -Define some SPM options (origins) when converting to the Analyze format. The quantification is not set. See also '-spm' & '-ar'. The interactive routine asks the following questions: +.B \-optspm, \-\-options\-spm +Define some SPM options (origins) when converting to the Analyze format. The quantification is not set. See also '\-spm' & '\-ar'. The interactive routine asks the following questions: .PP .in 0.2i .ti +0.8i @@ -411,8 +411,8 @@ Origin Z? .PP .TP -.B -p, --print-values -Show some specified pixel values. This is an interactive routine. Calibration and negative pixels are preserved automatically. You need to specify the -qs to preserve the quantification instead of the calibration. You can not use this option with -c. See also -pa option for a non-interactive routine. +.B \-p, \-\-print-values +Show some specified pixel values. This is an interactive routine. Calibration and negative pixels are preserved automatically. You need to specify the \-qs to preserve the quantification instead of the calibration. You can not use this option with \-c. See also \-pa option for a non-interactive routine. .PP .in 0.2i .ti +0.8i @@ -452,29 +452,29 @@ Give beds list? Give a list of pixels x,y ? .TP -.B -pa, --print-all-values +.B \-pa, \-\-print\-all\-values Show all pixel values. This option is identical to -p, but doesn't require user input. .TP -.B -pad, --pad-around +.B \-pad, \-\-pad\-around .TP -.B -padtl, --pad-top-left +.B \-padtl, \-\-pad\-top\-left .TP -.B -padbr, --pad-bottom-right +.B \-padbr, \-\-pad\-bottom\-right Increasing the slice matrix is done by padding an image with the lowest pixel value. The options above enable different padding modes. .TP -.B -preacq, --prefix-acquisition +.B \-preacq, \-\-prefix\-acquisition .TP -.B -preser, --prefix-series -Respectivily use acquisition or series value in the numbered prefix of the new filename. This is useful for alphabetical file ordering, where leading zeros in DICOM elements are missing. See also -alias. +.B \-preser, \-\-prefix\-series +Respectivily use acquisition or series value in the numbered prefix of the new filename. This is useful for alphabetical file ordering, where leading zeros in DICOM elements are missing. See also \-alias. .TP -.B -q, --quantitation +.B \-q, \-\-quantitation Enable quantitation using all scale factors (for now alias for -qc option). .TP -.B -qs, --quantification +.B \-qs, \-\-quantification A first scaling option to preserve the (ECAT) quantification (a) or to consider a first linear scaling slope with intercept (b). .PP .in 1.0i @@ -492,11 +492,11 @@ The "quant_scale" factor normalizes all .PP If the format does not support floats, the quantified pixel values get rescaled to an integer. Then only formats that support a global scaling factor or slope/intercept pair will preserve those quantified values. .PP -Note that this option can not be used with -qc. +Note that this option can not be used with \-qc. .PP .TP -.B -qc, --calibration +.B \-qc, \-\-calibration A second quantitation option to preserve the (ECAT) quantification as well as the (ECAT) calibration (a) or in general, using two rescale slopes with an intercept (b). These should normally transform pixels into manufacturer independent values. So one can assume that after a calibration, the new pixels will represent a real world unit (like concentration values (SUV), hounsfield units (HU) and alike). .PP @@ -518,81 +518,81 @@ The "quant_scale" factor normalizes all If the format does not support floats, the calibrated pixel values are rescaled to an integer type. Only formats that support a global scaling factor or slope/intercept pair preserve those calibrated values. .PP -Note that this option can not be used with -qs. +Note that this option can not be used with \-qs. .TP -.B -r, --rename-file +.B \-r, \-\-rename\-file Rename the file basename. This option is only useful in case of conversion. .TP -.B -rs, --reverse-slices -Reverse all the slices along the Z-axis. Parameters such as slice orientation are NOT changed. See also the -fh and -fv options. +.B \-rs, \-\-reverse\-slices +Reverse all the slices along the Z\-axis. Parameters such as slice orientation are NOT changed. See also the \-fh and \-fv options. .TP -.B -s, --silent +.B \-s, \-\-silent Suppress all message, warning and error dialogs. .TP -.B -sag, --sagittal +.B \-sag, \-\-sagittal Reslice the images of a volume into a sagittal projection while preserving the real world dimensions. .TP -.B -si=: -Force remap of pixel values using specified slope/intercept (y = s*x + i). The quantitation option -qc is enabled by default. No spaces are allowed within this option. +.B \-si=: +Force remap of pixel values using specified slope/intercept (y = s*x + i). The quantitation option \-qc is enabled by default. No spaces are allowed within this option. .TP -.B -skip1, --skip-preview-slice +.B \-skip1, \-\-skip\-preview\-slice Skip the first image in an InterFile. In other words, the first image in the array will simply be ignored. Use this only when you are sure that the InterFile does contain an annoying/confusing preview slice. .TP -.B -split4d, -splitf, --split-frames +.B \-split4d, \-splitf, \-\-split\-frames .TP -.B -split3d, -splits, --split-slices +.B \-split3d, \-splits, \-\-split\-slices Write out a study into separate files, one for each volume in a time frame (--split-frames) or each image slice (--split-slices) individually. The names of the files created will have an extra index number. See also -stack3d and -stack4d as opposite options. .TP -.B -spm, --analyze-spm +.B \-spm, \-\-analyze\-spm Considering Analyze files for/from SPM. In this case the global scaling factor hidden in imd.funused[1] will be used, as well as the hidden offset value in imd.funused[0]. .PP -In case of quantitation, the default output pixel type is float. This option allows to write integers combined with a global scale factor. To actually use this scaling factor, you must select a quantitation option like -qs or -qc as well. +In case of quantitation, the default output pixel type is float. This option allows one to write integers combined with a global scale factor. To actually use this scaling factor, you must select a quantitation option like \-qs or \-qc as well. .PP -See also -ar & -optspm. +See also \-ar & \-optspm. .TP -.B -sqr, --make-square -Make all image matrices square, using the largest dimension. Images are padded with the lowest pixel value. See also -pad related options. +.B \-sqr, \-\-make\-square +Make all image matrices square, using the largest dimension. Images are padded with the lowest pixel value. See also \-pad related options. .TP -.B -sqr2, --make-square-two -Make all image matrices square, using the nearest power of two (between 64, 128, 256, 512 and 1024). Images are padded with the lowest pixel value. See also -pad related options. +.B \-sqr2, \-\-make\-square\-two +Make all image matrices square, using the nearest power of two (between 64, 128, 256, 512 and 1024). Images are padded with the lowest pixel value. See also \-pad related options. .TP -.B -stack4d, -stackf, --stack-frames +.B \-stack4d, \-stackf, \-\-stack\-frames .TP -.B -stack3d, -stacks, --stack-slices -Write separate studies into one file. The --stack-slices option allows to write single image slice files into one 3D volume, while the --stack-frames option allows volumes of different time frames being written into one 4D file. The sequence of stacking is based on the file sequence given at the argument line. See also -split3d and -split4d as the opposite options. +.B \-stack3d, \-stacks, \-\-stack\-slices +Write separate studies into one file. The \-\-stack\-slices option allows one to write single image slice files into one 3D volume, while the \-\-stack\-frames option allows volumes of different time frames being written into one 4D file. The sequence of stacking is based on the file sequence given at the argument line. See also \-split3d and \-split4d as the opposite options. .TP -.B -tra, --transverse +.B \-tra, \-\-transverse Reslice the images of a volume into a transverse projection while preserving the real world dimensions. .TP -.B -uin, --use-institution-name +.B \-uin, \-\-use\-institution\-name Change the program's default institution name which is applied on studies without one. However, this does .B not override existing values. For a namestring with spaces, group between double quotes. .TP -.B -v, --verbose +.B \-v, \-\-verbose Verbose mode. Show some explaining messages during the reading and writing of files. .TP -.B -vifi, --edit-fileinfo +.B \-vifi, \-\-edit\-fileinfo An interactive routine for editing voxel,array,slice and orient related entries in the FILEINFO struct. .TP -.B -w, --overwrite-files +.B \-w, \-\-overwrite\-files Allow overwrite of existing files, without warning. .in 0.2i @@ -644,13 +644,13 @@ Enable this by using an "-" mark instead .PP .in 1.0i 1. redirect: -.B medcon -f - < inputfile +.B medcon \-f - < inputfile .PP This is supported for all formats and shouldn't cause any particular problems. Interactive routines are disabled because stdin is now in use by the image input. .PP .in 1.0i 2. pipes : -.B cat inputfile | medcon -f - format +.B cat inputfile | medcon \-f - format .PP Actually, this way only one or two formats are supported since seek() calls are not possible during pipes. The fact is that most of our formats are read using those seek() calls. In normal operation we already need a quick sneak in the file to determine the format. Because this fseek() isn't allowed, you must supply at least the input format too. .PP @@ -660,7 +660,7 @@ Actually, this way only one or two forma Enabled by using an extra "-" mark on the conversion list. .PP .in 1.0i -.B medcon -f inputfile -c - format +.B medcon \-f inputfile \-c - format .PP Only one inputfile is allowed. The converted output will be send to stdout. .PP @@ -668,7 +668,7 @@ In case of dual file formats such as Ana .PP In case of RAW or ASCII output, the program will print the content of the internal FILEINFO struct to stderr as well. Please note that the (t)csh shells do not allow to catch stderr or stdout separately. In case of the bash shell, it is possible to say: .PP -.B medcon -f inputfile -c - intf -b16.12 -qc 1>image 2>header +.B medcon \-f inputfile \-c - intf \-b16.12 \-qc 1>image 2>header .PP .in 0.2i .SH EXAMPLES @@ -677,37 +677,37 @@ In case of RAW or ASCII output, the prog .B 1. To display the image headers: .ti +1.0i -medcon -f filename1 filename2 +medcon \-f filename1 filename2 .PP .in 0.2i .B 2. To convert the images: .ti +1.0i -medcon -f filename1 filename2 -c gif acr intf +medcon \-f filename1 filename2 \-c gif acr intf .PP .in 0.2i .B 3. To read interactively .ti +1.0i -medcon -i -f filename -c ecat +medcon \-i \-f filename \-c ecat .PP .in 0.2i .B 4. To extract alternate images: .ti +1.0i -medcon -e 1:2:20 -f filename -c gif +medcon \-e 1:2:20 \-f filename \-c gif .PP .in 0.2i .B 5. To print out pixel values .ti +1.0i -medcon -p -f filename +medcon \-p \-f filename .PP .in 0.2i .B 6. Convert to raw binary images, send to standard output: .ti +1.0i -medcon -f filename -c - bin +medcon \-f filename \-c - bin .PP .in 0.2i .SH FILES --- a/man/xmedcon.1 +++ b/man/xmedcon.1 @@ -1,19 +1,19 @@ '\" t .TH MEDCON 1 .SH NAME -xmedcon - MedCon with GUI for the X Window System +xmedcon \- MedCon with GUI for the X Window System .SH SYNOPSIS .PP .in 0.2i .HP 7 .B xmedcon -[options] [-f ] +[options] [\-f ] .PP .in 0.8i or .PP .B xmedcon -[--help | ] +[\-\-help | ] .PP .br .SH DESCRIPTION @@ -23,7 +23,7 @@ or is an X-Windows graphical userinterface built around the MedCon library. The program is capable of reading grayscale (reconstructed) medical image formats with multiple images and is based on the amazing Gtk+ and Imlib libraries. .PP .in 0.2i -For more help read the related HTML files which can be send to a Netscape Browser from within the program. For information about the possible MedCon options that can be set directly from the command-line type 'xmedcon --help' or read the man-page medcon(1). +For more help read the related HTML files which can be send to a Netscape Browser from within the program. For information about the possible MedCon options that can be set directly from the command-line type 'xmedcon \-\-help' or read the man\-page medcon(1). .SH FILES .PP --- a/man/xmedcon-config.1 +++ b/man/xmedcon-config.1 @@ -6,7 +6,7 @@ xmedcon-config - script to get info abou .in 0.2i .HP 7 .B xmedcon-config -[--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--libs] [--cflags] +[\-\-prefix[=DIR]] [\-\-exec\-prefix[=DIR]] [\-\-version] [\-\-libs] [\-\-cflags] .SH DESCRIPTION .PP .in 0.2i @@ -17,24 +17,24 @@ is a tool that is used to determine the .in 0.2i .TP -.B --version +.B \-\-version Print the currently installed version of (X)MedCon on the standard output. .TP -.B --libs +.B \-\-libs Print the linker flags that are necessary to link an (X)MedCon depended program. .TP -.B --cflags +.B \-\-cflags Print the compiler flags that are necessary to compile an (X)MedCon depended program. .TP -.B --prefix=PREFIX -If specified, use PREFIX instead of the installation prefix that (X)MedCon was built with when computing the output for the --cflags and --libs options. This option is also used for the exec prefix if --exec-prefix was not specified. This option must be specified before any --libs or --cflags options. +.B \-\-prefix=PREFIX +If specified, use PREFIX instead of the installation prefix that (X)MedCon was built with when computing the output for the \-\-cflags and \-\-libs options. This option is also used for the exec prefix if \-\-exec-prefix was not specified. This option must be specified before any \-\-libs or \-\-cflags options. .TP -.B --exec-prefix=PREFIX -If specified, use PREFIX instead of the installation exec prefix that (X)MedCon was built with when computing the output for the --cflags and --libs options. This option must be specified before any --libs or --cflags options. +.B \-\-exec\-prefix=PREFIX +If specified, use PREFIX instead of the installation exec prefix that (X)MedCon was built with when computing the output for the \-\-cflags and \-\-libs options. This option must be specified before any \-\-libs or \-\-cflags options. .PP .in 0.2i .SH SEE ALSO @@ -56,8 +56,7 @@ medcon(3) project was originally written by Erik Nolf (eNlf) for the former PET-Centre at Ghent University (Belgium). .PP .in 0.2i -.TS -tab(=); -lB l lB l. -e-mail:=enlf-at-users.sourceforge.net=www:=http://xmedcon.sourceforge.net -.TE +.TP +e-mail: enlf@users.sourceforge.net +.TP +www: http://xmedcon.sourceforge.net --- a/man/medcon.3 +++ b/man/medcon.3 @@ -584,14 +584,14 @@ Example `Makefile' for compiling `testit ----------------------------------------------------------------------- # filename: Makefile CC = gcc -CCOPTS = -Wall -g +CCOPTS = \-Wall \-g CFLAGS = $(CCOPTS) -INCS = `xmedcon-config --cflags` -LIBS = `xmedcon-config --libs` +INCS = `xmedcon-config \-\-cflags` +LIBS = `xmedcon-config \-\-libs` testit: testit.c - $(CC) $(CFLAGS) $(INCS) -o testit testit.c $(LIBS) + $(CC) $(CFLAGS) $(INCS) \-o testit testit.c $(LIBS) # don't forget a before $(CC). You can lose this with copy/paste ----------------------------------------------------------------------- --- a/man/m-intf.4 +++ b/man/m-intf.4 @@ -338,7 +338,7 @@ for ( number of energy windows, energy w ;either an integer or a float, for each image } - ;End of frame loop -Repeat for each subsequent frame + ;End of frame loop - Repeat for each subsequent frame } ;End of static definitions debian/patches/avoid_linking_to_unneeded_libs.patch0000644000000000000000000000175212214301204020027 0ustar Author: Andreas Tille LastChanged: Tue, 23 Jul 2013 08:46:18 +0200 BugClosed: http://bugs.debian.org/632163 Description: Avoid useless linking against GTK library for command line tool and library --- a/source/Makefile.am +++ b/source/Makefile.am @@ -22,7 +22,6 @@ bin_PROGRAMS = medcon $(XMEDCON) medcon_SOURCES = medcon.c medcon_LDADD = libmdc.la -medcon_LDFLAGS = $(XMEDCON_GLIB_LIBS) $(XMEDCON_GTK_LIBS) -lm xmedcon_SOURCES = \ xcolmap.c \ @@ -212,8 +211,8 @@ libmdc_la_SOURCES = \ libmdc_la_LDFLAGS = $(no_undefined) -version-info $(LIBVERSION) -lm libmdc_la_LIBADD = $(ENABLED_FRMTS_OBJS) \ $(DICM_LIB) $(LJPG_LIB) \ - $(ZLIB_LIB) $(PNG_LIB) $(NIFTI_LIB) \ - $(TPC_LIB) $(XMEDCON_GLIB_LIBS) $(XMEDCON_GTK_LIBS) + $(PNG_LIB) $(NIFTI_LIB) \ + $(TPC_LIB) $(XMEDCON_GLIB_LIBS) libmdc_la_DEPENDENCIES = $(ENABLED_FRMTS_OBJS) EXTRA_libmdc_la_SOURCES = $(ALL_FRMTS_SOURCES) debian/patches/code-spelling.patch0000644000000000000000000001404412214301204014353 0ustar Author: Andreas Tille LastChanged: Tue, 23 Jul 2013 08:46:18 +0200 Description: Fix some spelling errors in code --- a/source/m-getopt.c +++ b/source/m-getopt.c @@ -986,7 +986,7 @@ int MdcHandleArgs(FILEINFO *fi, int argc /* print database info; legacy option, just used within ECAT */ if (MDC_INFO_DB == MDC_YES) { if (total[MDC_FILES] > 1) - MdcPrntErr(MDC_NO_CODE,"Option '-db' only usefull one file at a time"); + MdcPrntErr(MDC_NO_CODE,"Option '-db' only useful one file at a time"); if (MDC_CONVERT == MDC_YES) MdcPrntErr(MDC_NO_CODE,"Option '-db' useless with '-c' conversion"); } @@ -994,7 +994,7 @@ int MdcHandleArgs(FILEINFO *fi, int argc /* echo alias name; single option allowed */ if (MDC_ECHO_ALIAS == MDC_YES) { if (total[MDC_FILES] > 1) - MdcPrntErr(MDC_NO_CODE,"Option '-ean' only usefull one file at a time"); + MdcPrntErr(MDC_NO_CODE,"Option '-ean' only useful one file at a time"); if (MDC_CONVERT == MDC_YES) MdcPrntErr(MDC_NO_CODE,"Option '-ean' useless with '-c' conversion"); } --- a/source/m-split.c +++ b/source/m-split.c @@ -286,7 +286,7 @@ char *MdcSplitSlices(FILEINFO *fi, int f fi->nr_instance = instance; MdcCleanUpFI(ofi); MdcFree(ofi); MdcFree(tpath); - return("Failure to write splitted slice"); + return("Failure to write split slice"); } MdcCleanUpFI(ofi); @@ -374,7 +374,7 @@ char *MdcSplitFrames(FILEINFO *fi, int f fi->nr_instance = instance; MdcCleanUpFI(ofi); MdcFree(ofi); MdcFree(tpath); - return("Failure to write splitted frame"); + return("Failure to write split frame"); } MdcCleanUpFI(ofi); --- a/source/m-acr.c +++ b/source/m-acr.c @@ -473,7 +473,7 @@ const char *MdcReadACR(FILEINFO *fi) /* get endian of file */ r = fread((Uint8 *)tag, 1, MDC_ACR_TAG_SIZE, fi->ifp); - if (r != MDC_ACR_TAG_SIZE) return("ACR Failure to read tag (endianess)."); + if (r != MDC_ACR_TAG_SIZE) return("ACR Failure to read tag (endianness)."); if (tag->group == 0x0008) MDC_FILE_ENDIAN = MDC_HOST_ENDIAN; else { --- a/source/m-algori.c +++ b/source/m-algori.c @@ -1016,7 +1016,7 @@ char *MdcImagesPixelFiddle(FILEINFO *fi) } } - /* from here on, endianess is host based */ + /* from here on, endianness is host based */ MDC_FILE_ENDIAN = MDC_HOST_ENDIAN; return(NULL); --- a/source/m-conc.c +++ b/source/m-conc.c @@ -115,7 +115,7 @@ char * MdcConcAcqModeNames[MDC_CONC_NUM_ "Emission", "Dynamic", "Gated", - "Continous bed motion", + "Continuous bed motion", "Singles transmission", "Windowed Coincidence transmission", "Non-windowed Coincidence transmission" @@ -123,7 +123,7 @@ char * MdcConcAcqModeNames[MDC_CONC_NUM_ char * MdcConcBedMotionNames[MDC_CONC_NUM_BED_MOTIONS] = { "Static or unknown bed motion", - "Continous bed motion", + "Continuous bed motion", "Multiple bed positions" }; @@ -150,7 +150,7 @@ char * MdcConcOrderModeNames[MDC_CONC_NU }; char * MdcConcRebinTypeNames[MDC_CONC_NUM_REBIN_TYPES] = { - "Unknown, or no, algorith type", + "Unknown, or no, algorithm type", "Full 3D binning (span and ring difference)", "Single-Slice Rebinning", "Fourier Rebinning" --- a/source/m-conc.h +++ b/source/m-conc.h @@ -83,7 +83,7 @@ typedef enum { MDC_CONC_ACQ_EMISSION, /* Emission acquisition */ MDC_CONC_ACQ_DYNAMIC, /* Dynamic acquisition */ MDC_CONC_ACQ_GATED, /* Gated acquisition */ - MDC_CONC_ACQ_CONTINUOUS, /* Continous bed motion acquisition */ + MDC_CONC_ACQ_CONTINUOUS, /* Continuous bed motion acquisition */ MDC_CONC_ACQ_SINGLES, /* Singles transmission acquisition */ MDC_CONC_ACQ_WINDOWED_COINCIDENCE, /* Windowed coincidence transmission acquisition */ MDC_CONC_ACQ_NON_WINDOWED_COINCIDENCE, /* Non-windowed coincidence transmission acquisition */ @@ -100,7 +100,7 @@ typedef enum { typedef enum { MDC_CONC_BED_MOTION_STATIC, /* Static or unknown bed motion */ - MDC_CONC_BED_MOTION_CONTINOUS, /* Continous bed motion */ + MDC_CONC_BED_MOTION_CONTINOUS, /* Continuous bed motion */ MDC_CONC_BED_MOTION_MULTIPLE, /* Multiple bed positions, i.e. step and shoot */ MDC_CONC_NUM_BED_MOTIONS } MdcConcBedMotion; @@ -131,7 +131,7 @@ typedef enum { } MdcConcOrderModes; typedef enum { - MDC_CONC_REBIN_UNKNOWN, /* Unknown, or no, algorith type */ + MDC_CONC_REBIN_UNKNOWN, /* Unknown, or no, algorithm type */ MDC_CONC_REBIN_FULL, /* Full 3D binning (span and ring difference) */ MDC_CONC_REBIN_SINGLE, /* Single-Slice Rebinning */ MDC_CONC_REBIN_FOURIER, /* Fourier Rebinning */ --- a/source/m-nifti.c +++ b/source/m-nifti.c @@ -328,7 +328,7 @@ const char *MdcWriteNIFTI(FILEINFO *fi) /* file endian */ if (MDC_WRITE_ENDIAN != MDC_HOST_ENDIAN) - return("NIFTI Writing in different endianess yet unsupported"); + return("NIFTI Writing in different endianness yet unsupported"); /* get nifti_image struct */ nim = nifti_simple_init_nim(); --- a/source/m-ecat64.c +++ b/source/m-ecat64.c @@ -261,9 +261,9 @@ const char *MdcReadECAT6(FILEINFO *fi) MdcPrntScrn("Bed Offset[%02d] : %f [cm]\n",i+1 ,mh.bed_offset[i]); MdcPrntScrn("Plane Separation : %f [cm]\n",mh.plane_separation); - MdcPrntScrn("Lower Scatter Treshold : %d [KeV]\n",mh.lwr_sctr_thres); - MdcPrntScrn("Lower True Treshold : %d [KeV]\n",mh.lwr_true_thres); - MdcPrntScrn("Upper True Treshold : %d [KeV]\n",mh.upr_true_thres); + MdcPrntScrn("Lower Scatter Threshold : %d [KeV]\n",mh.lwr_sctr_thres); + MdcPrntScrn("Lower True Threshold : %d [KeV]\n",mh.lwr_true_thres); + MdcPrntScrn("Upper True Threshold : %d [KeV]\n",mh.upr_true_thres); MdcPrntScrn("Collimator : %6.0f\n",mh.collimator); MdcPrntScrn("User Process Code : "); MdcPrintStr(mh.user_process_code); debian/patches/series0000644000000000000000000000015612204407510012027 0ustar man-spelling.patch code-spelling.patch avoid_linking_to_unneeded_libs.patch add_gtk_libraries_to_linker.patch debian/xmedcon.menu0000644000000000000000000000023512214301204011476 0ustar ?package(xmedcon):needs="X11" section="Applications/Science/Medicine"\ title="xmedcon" command="/usr/bin/xmedcon"\ icon="/usr/share/pixmaps/xmedcon.xpm" debian/libmdc2.install0000644000000000000000000000004112214301204012052 0ustar debian/tmp/usr/lib/*/libmdc.so.* debian/compat0000644000000000000000000000000212214301204010351 0ustar 9 debian/medcon.install0000644000000000000000000000010112214301204012000 0ustar debian/tmp/usr/share/man/man1/medcon.1 debian/tmp/usr/bin/medcon debian/docs0000644000000000000000000000000712214301204010023 0ustar README debian/Readme.siemens_mosaic0000644000000000000000000000431612214301204013274 0ustar What is the mosaic format? From what a Philipps engineer told me DICOM is supposed to be able to handle 3 and 4dimensional data eventually (xmedcon can handle 3 dim data in several slices in one file). But there is no conformance statement out (which I think is not a real reason since none of the producers feel too obligated to any standard) so at the moment only one slice per file is DICOM standard. Siemens built a format formally complying to the standard by setting the slices together in one plane. Even though the Siemens' idea was/is good, it was problematic converting the data into other formats. While (X)medcon did a great job in converting normal 1slice/1file data it couldn't handle mosaic data. So I took the libmdc from medcon put a hack around it and could convert mosaic files. This wild hack was put proberly into medcon by Eric Nolf (thanks a lot) around April 2001. Everything was fine. After a discussion in the spm-mailing list I couldn't be nice and quiet (having a solution for my own data) but had to write to everybody why they didn't use the solution medcon gave them. They sent me some data. Needles to say Siemens created a whole new version of their mosaic DICOM files :-(((( What to do? (After Eric put in the new -fmosaic option in 0.7.7) For older Siemens Vision dicoms the automatic mosaic (option -mosaic) might work. If it doesn't. Use the -fmosaic option with the apropriate numbers for your format (you can try with xmedcon first using the medcon option dialog). Look at your converted voxel sizes. If they are to small try the -mfixv (for xy Plane sizes) or the -gap option (for slice thickness). I still didn't give up the idea of automatic detection but I need Siemens insider info for that. I you (or someone you know) know something about the tags coding this info pleas send me a message. R.M. Rutschmann 30.4.2002 Update 9.10.2002: I did get information by a Siemens programmer. Unfortunatly he told me that there is no way of getting the relevant information from the DICOM format. According to him the information I got for the old format is unreliable. So unless somebody comes up with a real good idea I give up on automatic detection. -fmosaic must be good enough. debian/xmedcon.install0000644000000000000000000000013412214301204012176 0ustar debian/tmp/usr/share/man/man1/xmedcon.1 debian/tmp/usr/bin/xmedcon debian/tmp/etc/xmedconrc