Skip to content

Commit

Permalink
python save for 3 or 4 images to prevent header issue
Browse files Browse the repository at this point in the history
  • Loading branch information
XeniosP committed Aug 4, 2023
1 parent 7041a6f commit fff544c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
8 changes: 5 additions & 3 deletions biswebpython/core/bis_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,11 @@ def save(self,fname):
try:
out_image = nib.Nifti1Image(self.data_array, self.affine);
# Preserve temporal spacing
out_image.header['pixdim'][4]=self.spacing[3]
out_image.header['pixdim'][5]=self.spacing[4]

try:
out_image.header['pixdim'][4]=self.spacing[3]
out_image.header['pixdim'][5]=self.spacing[4]
except:
print('')

nib.save(out_image, fname)
self.filename=fname;
Expand Down
2 changes: 1 addition & 1 deletion biswebpython/core/bis_wasmutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def load_library(name=''):
print('____ Recomputing name:',name);


print('___ Loading library from',name);
# print('___ Loading library from',name);
m=ctypes.CDLL(name);
if (m.uses_gpl()):
print("____ Library Loaded from",name,"result=",m.test_wasm(),' (should be 1700)');
Expand Down
7 changes: 3 additions & 4 deletions cpp/bisExportedFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,9 @@ unsigned char* extractImageFrameWASM(unsigned char* input,
int target_type=bisDataTypes::getTypeCodeFromName(params->getValue("datatype"),header[1]);

switch (target_type)
{
bisvtkTemplateMacro( return extractImageFrameTemplate(input,params.get(),debug, static_cast<BIS_TT*>(0)));
}
{
bisvtkTemplateMacro( return extractImageFrameTemplate(input,params.get(),debug, static_cast<BIS_TT*>(0)));
}
return 0;


Expand Down Expand Up @@ -885,7 +885,6 @@ unsigned char* butterworthFilterWASM(unsigned char* input_ptr,const char* jsonst
// Butterworth Filter Image
// ------------------------


unsigned char* butterworthFilterImageWASM(unsigned char* input_ptr,const char* jsonstring,int debug)
{

Expand Down
16 changes: 11 additions & 5 deletions cpp/bisfMRIAlgorithms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ namespace bisfMRIAlgorithms {
std::string passType,float frequency,float sampleRate,int removeMean,int debug) {


std::cout << "Begin FILTER IMage TR=" << sampleRate << ", removeMean=" << removeMean << std::endl;
std::cout << "Begin FILTER Image TR=" << sampleRate << ", removeMean=" << removeMean << std::endl;

int dim[5]; input_image->getDimensions(dim);
Eigen::MatrixXf temp;
Expand All @@ -427,7 +427,7 @@ namespace bisfMRIAlgorithms {

int ok=1;

//std::cout << "Dim=" << dim[0] << "," << dim[1] << "," << dim[2] << ", frames=" << dim[3] << " nv=" << numvoxels << std::endl;
std::cout << "Dim=" << dim[0] << "," << dim[1] << "," << dim[2] << ", frames=" << dim[3] << " nv=" << numvoxels << std::endl;

for (int i=0;i<numvoxels;i++)
{
Expand Down Expand Up @@ -462,9 +462,15 @@ namespace bisfMRIAlgorithms {
//std::cout << "Output" << std::endl;

for (int f=0;f<dim[3];f++) {
outdata[numvoxels*f+i]=output(f,0);
/*if (i==0)
std::cout << outdata[numvoxels*f+i] << std::endl;*/
float v=output(f,0);
if (std::isnan(v))
{
std::cerr << "Nan " << i << "," << f << std::endl;
v=0.0;
}
outdata[numvoxels*f+i]=v;
/* if (i==0)
std::cout << outdata[numvoxels*f+i] << std::endl;*/
}
}
return ok;
Expand Down

0 comments on commit fff544c

Please sign in to comment.