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

Fix normalize dm, and remove some transforms #597

Merged
merged 4 commits into from
Jun 8, 2019
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
2 changes: 1 addition & 1 deletion celery_worker/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def melt_dm(dm):

def plot_design_matrix(dm_wide, scale=True):
if scale:
dm_wide = dm_wide.apply(lambda x: x / x.max()) # Scale for plotting
dm_wide = (dm_wide - dm_wide.mean()) / (dm_wide.max() - dm_wide.min())
dm = melt_dm(dm_wide)

pts = alt.selection_multi(encodings=['x'])
Expand Down
25 changes: 3 additions & 22 deletions neuroscout/frontend/src/Transformations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This module comtains the following components:
- XformEditor: component to add/edit a transformtion
*/
import * as React from 'react';
import {
import {
Button,
Checkbox,
Col,
Expand Down Expand Up @@ -50,9 +50,6 @@ for (const item of transformDefinitions) {
const FormItem = Form.Item;
const RadioGroup = Radio.Group;

function weightsRequired(name) {
return (['Sum'].indexOf(name) >= 0);
}

export function validateXform(xform: Transformation) {
let errors: string[] = [];
Expand All @@ -62,28 +59,12 @@ export function validateXform(xform: Transformation) {
if (xform.Input === undefined || xform.Input.length < 1) {
errors.push('Please select at least one input for the transformation');
}
if (weightsRequired(xform.Name) && (xform.Weights && xform.Input)) {
if (xform.Weights.length !== xform.Input.length) {
errors.push('Each weight requires a value');
}
}
if ((xform.Name === 'Orthogonalize') && xform.Input !== undefined) {
if (xform.Other === undefined || xform.Other.length < 1) {
errors.push('Must orthoganalize with respect to at least one predictor');
}
}
if (xform.Name === 'Replace') {
let keys = Object.keys(xform.Replace);
let predecessor;
let replacement;
if (keys.length > 0) {
predecessor = keys[0];
}
if (predecessor === undefined || predecessor.length < 1) {
errors.push('Enter value to be replaced.');
}
}


return errors;
}

Expand Down Expand Up @@ -575,7 +556,7 @@ export class XformsTab extends React.Component<XformsTabProps, XformsTabState>
<List.Item className={this.getStyle(index)}>
<Draggable key={index} draggableId={'' + index} index={index}>
{(providedDraggable: DraggableProvided, snapshotDraggable: DraggableStateSnapshot) => (
<div
<div
style={{'width': '100%'}}
ref={providedDraggable.innerRef}
{...providedDraggable.dragHandleProps}
Expand Down
4 changes: 2 additions & 2 deletions neuroscout/frontend/src/coretypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ interface PredictorsParam {

export type Parameter = BooleanParam | PredictorsParam;

export type TransformName = 'Scale' | 'Orthogonalize' | 'Sum' | 'Product' | 'Threshold'
| 'Or' | 'And' | 'Not' | 'Convolve' | 'Replace';
export type TransformName = 'Scale' | 'Orthogonalize' | 'Threshold'
| 'Or' | 'And' | 'Not' | 'Convolve';

export type StepLevel = 'Run' | 'Session' | 'Subject' | 'Dataset';

Expand Down
11 changes: 0 additions & 11 deletions neuroscout/frontend/src/transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ const transformDefinitions: Transformation[] = [
Name: 'Orthogonalize',
Other: []
},
{
Name: 'Sum',
Weights: []
},
{
Name: 'Product'
},
{
Name: 'Threshold',
Threshold: 0,
Expand All @@ -60,10 +53,6 @@ const transformDefinitions: Transformation[] = [
},
{
Name: 'Not'
},
{
Name: 'Replace',
Replace: {}
}

];
Expand Down