Codebase list ciftilib / d901b52
Import upstream version 1.5.3+git20190401.108ddc2, md5 dba855c4726f5ef330f4e462a15fb86f Debian Janitor 4 years ago
5 changed file(s) with 31 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
44 Description: C++ Library for reading and writing CIFTI-2 and CIFTI-1 files
55 Version: @CIFTILIB_VERSION@
66 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@
88 Libs: -L${libdir} -lCifti
99 @CIFTILIB_PKGCONFIG_REQUIRES_LINE@
1818 if (argc < 3)
1919 {
2020 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;
2222 return 1;
2323 }
2424 try
2525 {
2626 CiftiFile inputFile(argv[1]);//on-disk reading by default
2727 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
2929 //otherwise, it will read and write one row at a time, using very little memory
3030 //inputFile.setWritingDataTypeNoScaling(NIFTI_TYPE_FLOAT32);//this is how you would revert back to writing as float32 without rescaling
3131 } catch (CiftiException& e) {
2020 }
2121 try
2222 {
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
2424 const CiftiXML& myXML = inputFile.getCiftiXML();
2525 for (int whichDim = 0; whichDim < myXML.getNumberOfDimensions(); ++whichDim)
2626 {
4141 #include <QString>
4242 namespace cifti
4343 {
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 };
4564 #define ASTRING_TO_CSTR(mystr) ((mystr).toLocal8Bit().constData())
4665 #define ASTRING_UTF8_RAW(mystr) ((mystr).toUtf8().constData())
4766 inline std::string AString_to_std_string(const AString& mystr)
304304 template<typename TO, typename FROM>
305305 TO NiftiIO::clamp(const FROM& in)
306306 {
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();
312313 } else {
313 if (-mylimits.max() > in) return -mylimits.max();
314 if (-mylimits::max() > in) return -mylimits::max();
314315 }
315316 return (TO)in;
316317 }