Skip to content

Commit

Permalink
Fix data crop method
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fitzpatrick committed Apr 30, 2014
1 parent 1cf9fd5 commit efc1ecf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions pathomx/data.py
Expand Up @@ -681,9 +681,9 @@ def crop(self,shape):
self.scales[d] = self.scales[d][:s]
self.classes[d] = self.classes[d][:s]
final_shape[d] = shape[d]
self.data.resize( final_shape )


# Crop numpy array to shape
self.data = self.data[ [slice(0,n) for n in shape] ]

@property
def is_empty(self):
Expand Down
7 changes: 3 additions & 4 deletions pathomx/plugins/pca/pca.py
Expand Up @@ -91,17 +91,15 @@ def generate(self, input=None):
scored.labels[0] = input.labels[0]
scored.classes[0] = input.classes[0]
scored.data = scores

for n in range(0, scored.shape[1]):
scored.labels[1][n] = 'Principal Component %d (%0.2f%%)' % (n+1, pca.explained_variance_ratio_[0] * 100.)

weightsd = DataSet(size=pca.components_.shape)
weightsd.data = pca.components_

weightsd.scales[1] = input.scales[1]

print weightsd.shape, "@"
print pca.components_.shape, "|"


dso_pc = {}
for n in range(0, pca.components_.shape[0] ):
Expand All @@ -123,6 +121,7 @@ def generate(self, input=None):

def prerender(self, dso=None, pca=None, scores=None, pc1=None, pc2=None, pc3=None, pc4=None, pc5=None, **kwargs):
scores.crop( (scores.shape[0], 2) )
print scores.data
return {
'Scores':{'dso': scores},
'PC1':{'dso':pc1},
Expand Down

0 comments on commit efc1ecf

Please sign in to comment.