Import upstream version 1.5.3+git20190401.108ddc2, md5 dba855c4726f5ef330f4e462a15fb86f
Debian Janitor
4 years ago
4 | 4 |
Description: C++ Library for reading and writing CIFTI-2 and CIFTI-1 files
|
5 | 5 |
Version: @CIFTILIB_VERSION@
|
6 | 6 |
URL: https://github.com/Washington-University/CiftiLib
|
7 | |
Cflags: -I${includedir}/CiftiLib @CIFTILIB_PKGCONFIG_DEFINE@
|
|
7 |
Cflags: -I${includedir}/CiftiLib @CIFTILIB_PKGCONFIG_DEFINE@ @OpenMP_CXX_FLAGS@
|
8 | 8 |
Libs: -L${libdir} -lCifti
|
9 | 9 |
@CIFTILIB_PKGCONFIG_REQUIRES_LINE@
|
18 | 18 |
if (argc < 3)
|
19 | 19 |
{
|
20 | 20 |
cout << "usage: " << argv[0] << " <input cifti> <output cifti>" << endl;
|
21 | |
cout << " rewrite the input cifti file to the output filename, using uint8 and data scaling." << endl;
|
|
21 |
cout << " rewrite the input cifti file to the output filename, using uint8 and data scaling, little-endian." << endl;
|
22 | 22 |
return 1;
|
23 | 23 |
}
|
24 | 24 |
try
|
25 | 25 |
{
|
26 | 26 |
CiftiFile inputFile(argv[1]);//on-disk reading by default
|
27 | 27 |
inputFile.setWritingDataTypeAndScaling(NIFTI_TYPE_UINT8, -1.0, 6.0);//tells it to use this datatype to best represent this specified range of values [-1.0, 6.0] whenever this instance is written
|
28 | |
inputFile.writeFile(argv[2]);//if this is the same filename as the input, CiftiFile actually detects this and reads the input into memory first
|
|
28 |
inputFile.writeFile(argv[2], CiftiVersion(), CiftiFile::LITTLE);//if this is the same filename as the input, CiftiFile actually detects this and reads the input into memory first
|
29 | 29 |
//otherwise, it will read and write one row at a time, using very little memory
|
30 | 30 |
//inputFile.setWritingDataTypeNoScaling(NIFTI_TYPE_FLOAT32);//this is how you would revert back to writing as float32 without rescaling
|
31 | 31 |
} catch (CiftiException& e) {
|
20 | 20 |
}
|
21 | 21 |
try
|
22 | 22 |
{
|
23 | |
CiftiFile inputFile(argv[1]);//on-disk reading by default, and we only need the XML header anyway
|
|
23 |
CiftiFile inputFile((string(argv[1])));//on-disk reading by default, and we only need the XML header anyway
|
24 | 24 |
const CiftiXML& myXML = inputFile.getCiftiXML();
|
25 | 25 |
for (int whichDim = 0; whichDim < myXML.getNumberOfDimensions(); ++whichDim)
|
26 | 26 |
{
|
41 | 41 |
#include <QString>
|
42 | 42 |
namespace cifti
|
43 | 43 |
{
|
44 | |
typedef QString AString;
|
|
44 |
struct AString : public QString
|
|
45 |
{//QT doesn't convert from std::string, and conversions have to be member functions
|
|
46 |
AString() {}
|
|
47 |
|
|
48 |
//make common copy case simple by not going through the below mess
|
|
49 |
AString(const AString& rhs) : QString(rhs) { }
|
|
50 |
|
|
51 |
//some QString constructors are explicit, so instead only make conversion constructors for whatever works with assignment to QString
|
|
52 |
//the cast is required to avoid recursing through AString
|
|
53 |
template <typename T>
|
|
54 |
AString(const T& rhs) : QString()
|
|
55 |
{
|
|
56 |
*(static_cast<QString*>(this)) = rhs;
|
|
57 |
}
|
|
58 |
|
|
59 |
AString(const std::string& rhs) : QString()
|
|
60 |
{
|
|
61 |
(*this) = fromStdString(rhs);
|
|
62 |
}
|
|
63 |
};
|
45 | 64 |
#define ASTRING_TO_CSTR(mystr) ((mystr).toLocal8Bit().constData())
|
46 | 65 |
#define ASTRING_UTF8_RAW(mystr) ((mystr).toUtf8().constData())
|
47 | 66 |
inline std::string AString_to_std_string(const AString& mystr)
|
304 | 304 |
template<typename TO, typename FROM>
|
305 | 305 |
TO NiftiIO::clamp(const FROM& in)
|
306 | 306 |
{
|
307 | |
std::numeric_limits<TO> mylimits;
|
308 | |
if (mylimits.max() < in) return mylimits.max();
|
309 | |
if (mylimits.is_integer)//c++11 can use lowest() instead of this mess
|
310 | |
{
|
311 | |
if (mylimits.min() > in) return mylimits.min();
|
|
307 |
typedef std::numeric_limits<TO> mylimits;
|
|
308 |
if (mylimits::has_infinity && std::isinf(in)) return (TO)in;//in case we use this on float types at some point
|
|
309 |
if (mylimits::max() < in) return mylimits::max();
|
|
310 |
if (mylimits::is_integer)//c++11 can use lowest() instead of this mess
|
|
311 |
{
|
|
312 |
if (mylimits::min() > in) return mylimits::min();
|
312 | 313 |
} else {
|
313 | |
if (-mylimits.max() > in) return -mylimits.max();
|
|
314 |
if (-mylimits::max() > in) return -mylimits::max();
|
314 | 315 |
}
|
315 | 316 |
return (TO)in;
|
316 | 317 |
}
|