Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dwifslpreproc: Handle non-ascii data in eddy error outputs #2313

Merged
merged 2 commits into from
May 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/dwifslpreproc
Original file line number Diff line number Diff line change
Expand Up @@ -912,13 +912,13 @@ def execute(): #pylint: disable=unused-variable
except run.MRtrixCmdError as exception_cuda:
if not eddy_openmp_cmd:
raise
with open('eddy_cuda_failure_output.txt', 'w') as eddy_output_file:
with open('eddy_cuda_failure_output.txt', 'wb') as eddy_output_file:
eddy_output_file.write(str(exception_cuda))
app.console('CUDA version of \'eddy\' was not successful; attempting OpenMP version')
try:
eddy_output = run.command(eddy_openmp_cmd + ' ' + eddy_all_options)
except run.MRtrixCmdError as exception_openmp:
with open('eddy_openmp_failure_output.txt', 'w') as eddy_output_file:
with open('eddy_openmp_failure_output.txt', 'wb') as eddy_output_file:
eddy_output_file.write(str(exception_openmp))
# Both have failed; want to combine error messages
eddy_cuda_header = ('=' * len(eddy_cuda_cmd)) \
Expand Down
12 changes: 6 additions & 6 deletions core/formats/tiff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ namespace MR
if (! (Path::has_suffix (H.name(), ".tiff") ||
Path::has_suffix (H.name(), ".tif") ||
Path::has_suffix (H.name(), ".TIFF") ||
Path::has_suffix (H.name(), ".TIF")))
Path::has_suffix (H.name(), ".TIF")))
return std::unique_ptr<ImageIO::Base>();

File::TIFF tif (H.name());

uint32 width(0), height(0);
uint16 bpp(0), sampleformat(0), samplesperpixel(0), config (0);
uint32_t width(0), height(0);
uint16_t bpp(0), sampleformat(0), samplesperpixel(0), config (0);
size_t ndir = 0;

do {
Expand All @@ -57,7 +57,7 @@ namespace MR

H.ndim() = samplesperpixel > 1 ? 4 : 3;

H.size(0) = width;
H.size(0) = width;
H.stride(0) = 2;

H.size(1) = height;
Expand All @@ -73,7 +73,7 @@ namespace MR

H.datatype() = DataType::Undefined;
switch (bpp) {
case 8:
case 8:
switch (sampleformat) {
case 1: H.datatype() = DataType::UInt8; break;
case 2: H.datatype() = DataType::Int8; break;
Expand Down Expand Up @@ -114,7 +114,7 @@ namespace MR
if (Path::has_suffix (H.name(), ".tiff") ||
Path::has_suffix (H.name(), ".tif") ||
Path::has_suffix (H.name(), ".TIFF") ||
Path::has_suffix (H.name(), ".TIF"))
Path::has_suffix (H.name(), ".TIF"))
throw Exception ("TIFF format not supported for output");

return false;
Expand Down
2 changes: 1 addition & 1 deletion core/image_io/tiff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace MR
for (auto& entry : files) {
File::TIFF tif (entry.name);

uint16 config (0);
uint16_t config (0);
tif.read_and_check (TIFFTAG_PLANARCONFIG, config);

size_t scanline_size = tif.scanline_size();
Expand Down