Skip to content

Commit

Permalink
Merge branch 'devel' of github.com:bioimagesuiteweb/bisweb into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
XeniosP committed Mar 5, 2024
2 parents 46b6dcc + e831350 commit 16b47f7
Show file tree
Hide file tree
Showing 24 changed files with 1,119 additions and 38 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
9 changes: 7 additions & 2 deletions biswebpython/modules/dualImageRegression.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ def createDescription(self):
},
{
"type": "image",
"name": "Input Image",
"name": "Regressor Image",
"description": "The input image (uv) to preprocess",
"varname": "regressor",
"shortname" : "r",
"required": False
"required": True
}
],
"outputs": [
Expand Down Expand Up @@ -130,10 +130,15 @@ def directInvokeAlgorithm(self,vals):
if (doregress):
print('.... computing dual image regression')
outdata=self.dualRegress(idata,rdata,debug);
else:
print('.... not computing dual image regression')
outdata=idata;

if (df):
print('.... computing df/f')
outdata=np.transpose((np.transpose(outdata)+mean)/mean)
else:
print('.... not computing df/f')

outdata=np.reshape(outdata,sz);
self.outputs['output'] = bis_objects.bisImage().create(outdata,input.spacing,input.affine);
Expand Down
26 changes: 21 additions & 5 deletions biswebpython/modules/initializeCalciumStudy.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,26 @@ def loadChannels(self,infilename,movies,usedframes,mat,spacing,triggers):
imgl=page.convert(mode='F')
v=np.array(imgl)
channel=triggers[c][1]-1
if (channel>0):
flag=0
# if (usedframes[0]>5900 or ( usedframes[0]>15 and usedframes[0]<20)):
# print('Channel=',triggers[c][1],'c=',c,' channel=',channel,' usedrames=',usedframes);
# flag=1

if (channel>=0):
movies[channel][:,:,0,usedframes[channel]] = np.array(imgl,dtype=np.uint16)
if (c%125==0 or c<4 or c>(expected_num_frames-4)):
s='...\t added frame {:5d}/{:5d} to channel {:d} as new frame {:5d} based on trigger {:s}'.format(c+1,expected_num_frames,channel+1,usedframes[channel]+1,str(triggers[c]))
else:
print('....\t\t Skipping ',triggers[c][1] ,' < 0 c=',c)

if (c%125==0 or c<4 or c>(expected_num_frames-4) or flag>0):
q='added';
if (channel<0):
q='not '+q;

s='...\t '+q+' frame {:5d}/{:5d} to channel {:d} as new frame {:5d} based on trigger {:s}'.format(c+1,expected_num_frames,channel+1,usedframes[channel]+1,str(triggers[c]))
print(s)
c=c+1;
usedframes[channel]=usedframes[channel]+1
if (channel>=0):
usedframes[channel]=usedframes[channel]+1
if (c>100 and DUMMY_MODE):
break

Expand Down Expand Up @@ -216,7 +229,10 @@ def convertRuns(self,data,indir,outdir):
lt=len(triggers)
for k in range(0,lt):
v=triggers[k][1]-1;
numframes[v]=numframes[v]+1;
if (v>=0 and v<numchannels):
numframes[v]=numframes[v]+1;
else:
print('........ ignoring part',part,' frame=',k,' as v=',v+1)
print('...\t processing', nm, 'cumulative numframes per channel=',numframes)


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
2 changes: 2 additions & 0 deletions js/coreweb/bisweb_connectivityvis.js
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,7 @@ var createlines = function() {
attribcomponent : attribcomponent,
filter: filter,
radius : globalParams.internal.parameters.radius,
maxdegree : globalParams.internal.parameters.maxdegree,
matrixthreshold : matrixthreshold};

if (globalParams.internal.hadlinesonce)
Expand All @@ -886,6 +887,7 @@ var drawlines=function(state) {
state.degreethreshold, // metric threshold
state.filter); // sum


if (ok===0) {
bootbox.alert('Failed to create flag matrix for connectivity data!');
return 0;
Expand Down
15 changes: 8 additions & 7 deletions js/coreweb/bisweb_connectivityvis3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -805,11 +805,11 @@ var drawlines3d=function(state,doNotUpdateFlagMatrix) {
if (!doNotUpdateFlagMatrix) {
console.log('.... Updating Flag Matrix\n');
let ok=globalParams.internal.conndata.createFlagMatrix(globalParams.internal.parcellation,
state.mode, // mode
state.singlevalue, // singlevalue
state.attribcomponent, // attribcomponent
state.degreethreshold, // metric threshold
state.filter); // sum
state.mode, // mode
state.singlevalue, // singlevalue
state.attribcomponent, // attribcomponent
state.degreethreshold, // metric threshold
state.filter); // sum

if (ok===0) {
bootbox.alert('Failed to create flag matrix for 3D connectivity data!');
Expand All @@ -820,7 +820,7 @@ var drawlines3d=function(state,doNotUpdateFlagMatrix) {


// Now add lines
let pos=[],neg=[],total=0;
let pos=[],eg=[],total=0;
if (state.linestodraw == globalParams.internal.gui_Lines[0] ||
state.linestodraw == globalParams.internal.gui_Lines[2] ) {
pos=globalParams.internal.conndata.createLinePairs(0,state.matrixthreshold);
Expand All @@ -844,8 +844,9 @@ var drawlines3d=function(state,doNotUpdateFlagMatrix) {
// console.log('Drawing 3D',state.poscolor,state.negcolor);

const ATLASHEADER=atlasutils.getCurrentAtlasHeader();
console.log('State=',JSON.stringify(state));
let lparr = globalParams.internal.conndata.draw3DLines(globalParams.internal.parcellation,
pos,neg,2.0,1.0,
pos,neg,2.0,1.0,state.maxdegree,
ATLASHEADER);
for (let i=0;i<=1;i++) {
let lp=lparr[i];
Expand Down
Loading

0 comments on commit 16b47f7

Please sign in to comment.