Skip to content

Instantly share code, notes, and snippets.

View Tehsurfer's full-sized avatar

Jesse Khorasanee Tehsurfer

View GitHub Profile
@Tehsurfer
Tehsurfer / arrow-nav.js
Last active June 10, 2019 23:35
Surf2surf.com video navigator
video = document.getElementsByTagName('video')[1]
window.addEventListener('keyup', function(e){
if (e.which == 37){
video.currentTime -= 5
} if (e.which == 39){
video.currentTime += 5
}
});
xl = np.array([3,4,0])
xi = xl/np.linalg.norm(xi)
yl = np.array([4,3,0])
norm = np.cross(yl,xi)
zi = norm/np.linalg.norm(norm)
yi = np.cross(zi,xi)
yi = yi/np.linalg.norm(yi)
#Transormation Matrix TM
TM = np.vstack([xi,yi,zi]).T
@Tehsurfer
Tehsurfer / strains.py
Created January 17, 2019 22:30
Strains calculation (xyz comparing by index)
def getPortData(self, index):
"""
Add your code here that will return the appropriate objects for this step.
The index is the index of the port in the port list. If there is only one
provides port for this step then the index can be ignored.
:param index: Index of the port to return.
"""
# Data can be pasted here to send to other steps for testing, or grabbed from a file if we have larger data
@Tehsurfer
Tehsurfer / routes.py
Last active November 29, 2018 09:46
a placeholder for routes.py
from flask import jsonify
from flask import request
from blackfynn import Blackfynn
import urllib2
from service.app import app
from service.config import Config
import json
import csv
import numpy as np
import json
import numpy as np
count = 0
indexlist = []
above12 = []
filename = "C:\\Users\jkho021\Projects\SPARC\mapclient\src\mapclient\ecgDataExtended2.json"
data = {}
with open(filename) as f:
data['cache'] = json.load(f)
@Tehsurfer
Tehsurfer / json_to_csv_functions.py
Last active November 20, 2018 00:34
A few functions for loading .json and writing it to OpenCOR and general csv
import csv, json, sys
import numpy as np
#if we are using utf-8 files, uncomment the next line
# sys.setdefaultencoding("UTF-8") #set the encode to utf8
def load_json(filename):
with open(filename) as f:
data = json.load(f)
return data
def _calculatePointOnPlane(self, x, y):
from opencmiss.utils.maths.algorithms import calculateLinePlaneIntersection
far_plane_point = self.unproject(x, -y, -1.0)
near_plane_point = self.unproject(x, -y, 1.0)
plane_point, plane_offset, plane_normal = self._model.getPlaneDescription()
point_on_plane = calculateLinePlaneIntersection(near_plane_point, far_plane_point, plane_point, plane_normal)
if len(self.grid) < 4:
self.grid.append(point_on_plane)
else:
@Tehsurfer
Tehsurfer / meshprojection.py
Last active October 31, 2018 00:12
A class for creating grids and projecting them onto the heart.
"""
Created on 30 MOct, 2018 from mapclientplugins.meshgeneratorstep.
@author: Jesse Khorasanee
"""
import numpy as np
from opencmiss.zinc.field import Field
from opencmiss.zinc.glyph import Glyph
from opencmiss.zinc.graphics import Graphics
@Tehsurfer
Tehsurfer / click4points.py
Created October 29, 2018 01:54
Modify your meshgeneratorwidget.py to record grid points
def init(self)
self._ui.sceneviewer_widget.grid = []
def keyReleaseEvent(self, event):
if self._marker_mode_active:
self._marker_mode_active = False
self._ui.sceneviewer_widget._model = self._plane_model
self._ui.sceneviewer_widget._calculatePointOnPlane = None
self._ui.sceneviewer_widget.mousePressEvent = self._original_mousePressEvent
if len(self._ui.sceneviewer_widget.grid) is 4:
@Tehsurfer
Tehsurfer / generateGridPoints4.py
Created October 29, 2018 01:45
A function that takes in four points in 3D space on a plane and creates a grid between them
def generateGridPoints4(pointsList, number_on_side, plane_normal):
# We generate our grid points by having 4 points that we assign weightings to
# based on how far we are away from them.
# INPUTS:
# pointsList : a list of four points defined in any 3D space.
# number_on_side : the number of nodes we have on each side of our array (ie 8 nodes if we have a 64 point grid).
# plane_normal : the normal of the plane we are creating points in. EG [0,0,1] for the x,y plane.
# OUTPUTS: