void InitModelingView(EdmDraw.EdmConfig edmConfig, ElecManage.Electrode elec, bool isAutoMode = true) { if (IsInitModelingView && !isAutoMode) { return; } SnapEx.Create.ApplicationSwitchRequest(SnapEx.ApplicationType.MODELING); var wcsOrientation = Electrode.GetStandardOrientation(Snap.Globals.WcsOrientation); var acsOrientation = Snap.Orientation.Identity; var baseDirOrientation = Electrode.GetSidelongOrientation(new Snap.Orientation(-elec.BaseFace.GetFaceDirection())); var transR = Snap.Geom.Transform.CreateRotation(acsOrientation, wcsOrientation); var transR1 = Snap.Geom.Transform.CreateRotation(baseDirOrientation, wcsOrientation); var draftViewLocations = edmConfig.DraftViewLocations ?? new List <EdmDraw.EdmConfig.DraftViewLocation>(); foreach (var item in draftViewLocations) { var viewType = EdmDraw.DrawBusiness.GetEumnViewType(item.ViewType); var X = new Snap.Vector(item.Xx, item.Xy, item.Xz).Copy(transR); var Y = new Snap.Vector(item.Yx, item.Yy, item.Yz).Copy(transR); if (viewType == EdmDraw.ViewType.EACT_BOTTOM || viewType == EdmDraw.ViewType.EACT_BOTTOM_FRONT || viewType == EdmDraw.ViewType.EACT_BOTTOM_ISOMETRIC ) { X = X.Copy(transR1); Y = Y.Copy(transR1); } EdmDraw.DrawBusiness.CreateCamera(viewType, new double[] { X.X, X.Y, X.Z, Y.X, Y.Y, Y.Z }); } IsInitModelingView = true; }
/// <summary> /// 克隆当前对象的原始值和当前值,并指定电极的类型 /// </summary> /// <param name="mode">指定电极的类型</param> /// <returns>克隆后的电极对象</returns> public Electrode Clone(PoleMode mode) { var pole = new Electrode(IdOrigin, IdCurrent) { Mode = mode }; return(pole); }
void FixedUpdate() { if (Constants.finishedInitialization.TrueForAll(b => b)) { //Neuronal spikes int wut = this.SpikeTimes.times.GetLength(0); //List<int> IDs = new List<int>(); float endTime = this.startTime + (Time.fixedDeltaTime * Constants.timeScale); //float totalTime = endTime - this.startTime; //float currentNeuronTime = this.SpikeTimes.times[this.currentSpikeIndex, 1]; //float currentNeuronTimeEnd = currentNeuronTime + Time.fixedDeltaTime; while (this.currentSpikeIndex < this.SpikeTimes.times.GetLength(0)) { if (this.SpikeTimes.times[this.currentSpikeIndex, 1] < endTime) { int neuronToSpike = (int)this.SpikeTimes.times[this.currentSpikeIndex, 0]; this.NeuronList[neuronToSpike - 1].GetComponent <Neuron>().spike(); this.currentSpikeIndex++; } else { break; } } //Electrode values int currentElectrodeTimeStep = Convert.ToInt32(Math.Floor(endTime)); for (this.electrodeIndex = 0; this.electrodeIndex < ElectrodeList.Length; this.electrodeIndex++) { if (currentElectrodeTimeStep < this.LFPData.LFPValues.GetLength(1)) { Electrode tmpElectrode = this.ElectrodeList[this.electrodeIndex].GetComponent <Electrode>(); if (tmpElectrode.LFP != this.LFPData.LFPValues[this.electrodeIndex, currentElectrodeTimeStep]) { tmpElectrode.ChangeSize(this.LFPData.LFPValues[this.electrodeIndex, currentElectrodeTimeStep]); } } else { break; } } //Debug.Log("Start time = " + Convert.ToString(this.startTime)); //Debug.Log("End time = " + Convert.ToString(endTime)); //Debug.Log("Change in time = " + Convert.ToString((Time.fixedDeltaTime * Constants.timeScale))); this.startTime = endTime; if (this.tissueInstance == 0) { Constants.currentTime = this.startTime; } } }
public Waveform GetEEGWaveform(Electrode electrode) { Waveform Waveform = new Waveform(0, sampleRate); foreach (EEGSample sample in goodSamples) { Waveform.Add(sample.eegValues[electrode]); } return Waveform; }
void AutoSelectPoint() { DeleteNodes(); var body = selectCuprum.GetSelectedObjects().FirstOrDefault() as NXOpen.Body; var pointDatas = new List <PointData>(); ComponentHelper((probeData) => { pointDatas = new Electrode(body).AutoSelectPointOnFace(probeData); }, enumSelectTool.ValueAsString); UFDisp(pointDatas); }
/// <summary> /// 电极排序方法 /// </summary> private static int CompareSort(Electrode x, Electrode y) { if (x.IdOrigin > y.IdOrigin) { return(1); } if (x.IdOrigin < y.IdOrigin) { return(-1); } return(0); }
public async Task ExecuteAsync(Electrode electrodeModel) { try { if (electrodeModel == null) { throw new ArgumentNullException(nameof(electrodeModel)); } using (var dbSession = dbFacade.Transaction()) { var electrode = await dbSession.Set <Electrode>().FirstOrDefaultAsync(e => e.ProductionOrderID == electrodeModel.ProductionOrderID); if (electrode == null) { throw new Exception($"Electrode with id = \"{electrodeModel.ID}\" does not exist."); } electrode.AmountAfterSaw = electrodeModel.AmountAfterSaw; electrode.BilletNumber = electrodeModel.BilletNumber; electrode.Diameter = electrodeModel.Diameter; electrode.Length = electrodeModel.Length; electrode.Photo = electrodeModel.Photo; electrode.SawCut = electrodeModel.SawCut; electrode.StubLength = electrodeModel.StubLength; electrode.StubNumber = electrodeModel.StubNumber; electrode.StubWeight = electrodeModel.StubWeight; electrode.UserID = electrodeModel.UserID; var order = await dbSession.Set <ProductionOrder>() .SingleOrDefaultAsync(p => p.ID == electrodeModel.ProductionOrderID); if (order == null) { throw new Exception($" There is no production order associated with Electrode of given id = \"{electrodeModel.ID}\" "); } var orderStatus = await dbSession.Set <ProductionOrderStatus>() .Where(x => x.Name == ProductionOrderStatus.Planned) .Select(x => new { x.ID }) .SingleAsync(); order.ProductionOrderStatusID = orderStatus.ID; await dbSession.SaveChangesAsync(); } } catch (Exception ex) { throw Oops.Rewrap(ex); } }
private void GetAllModel() { foreach (Part pt in Session.GetSession().Parts) { string name = pt.Name; if (ParentAssmblieInfo.IsParent(pt)) { ParentAssmblieInfo parent = ParentAssmblieInfo.GetAttribute(pt); switch (parent.Type) { case PartType.ASM: Asm.Add(new ASMModel(pt)); break; case PartType.EDM: Edm.Add(new EDMModel(pt)); break; case PartType.Electrode: ElectrodeModel eleModel = new ElectrodeModel(pt); Electrode.Add(eleModel); break; case PartType.Work: Work.Add(new WorkModel(pt)); break; default: Other.Add(pt); break; } } else { Other.Add(pt); } } }
/// <summary> /// ComboBox selection changed for the current EEG electrode. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void CurrentWaveComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { currentElectrode = (Electrode)((sender as ComboBox).SelectedItem); DrawWaveforms(); }
/// <summary> /// Set the current selected electrode for spectrum /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CurrentSpectrumComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { currentSpectrumElectrode = (Electrode)((sender as ComboBox).SelectedItem); DrawSpectrum(); }
public override void Update(NXOpen.BlockStyler.UIBlock block) { RefreshUI(); var body = selectCuprum.GetSelectedObjects().FirstOrDefault() as NXOpen.Body; if (block == btnAutoSelectPoint) { AutoSelectPoint(); RefreshUI(); } else if (block == toggle0) { UFDisp(); DeleteNodes(); } else if (block == btnDown) { var node = GetSelectNode(); if (node != null) { var list = GetNodes(); var index = list.IndexOf(node) + 1; index = index > list.Count - 1 ? list.Count - 1 : index; list.Remove(node); list.Insert(index, node); UFDisp(GetPointDatasFromTree(list)); } } else if (block == btnUP) { var node = GetSelectNode(); if (node != null) { var list = GetNodes(); var index = list.IndexOf(node) - 1; index = index < 0 ? 0 : index; list.Remove(node); list.Insert(index, node); UFDisp(GetPointDatasFromTree(list)); } } else if (block == btnRemove) { var node = GetSelectNode(); if (node != null) { var pd = GetPointData(node); if (pd != null && pd.PointType == PointType.HeadFace) { var list = GetNodes(); list.Remove(node); UFDisp(GetPointDatasFromTree(list)); theUI.NXMessageBox.Show("提示", NXOpen.NXMessageBox.DialogType.Information, "删除成功!"); } else { theUI.NXMessageBox.Show("提示", NXOpen.NXMessageBox.DialogType.Information, "无法删除该点!"); } } } else if (block == selectionPoint) { if (body != null && selectionPoint.GetSelectedObjects().Count() > 0) { PointData data = null; ComponentHelper((probeData) => { data = new Electrode(body).IsIntervene(selectionPoint.PickPoint, probeData); }, enumSelectTool.ValueAsString); if (data != null && data.PointType == PointType.HeadFace) { var points = GetPointDatasFromTree(); points.Add(data); UFDisp(points); } else { theUI.NXMessageBox.Show("提示", NXOpen.NXMessageBox.DialogType.Information, "无法取该点,请重新选点!"); } } selectionPoint.SetSelectedObjects(new NXOpen.TaggedObject[] { }); } else if (block == btnExport) { if (body != null) { var list = new List <PointData>(); GetNodes().ForEach(u => { list.Add(Newtonsoft.Json.JsonConvert.DeserializeObject <PointData>(u.GetNodeData().GetString(_propertyName))); }); if (list.Count > 0) { //导出 var info = new Electrode(body).GetPointInfo(list); var infoStr = Newtonsoft.Json.JsonConvert.SerializeObject(info); File.WriteAllText(@"D:\GetPointInfo.txt", infoStr); } } else { ImportPart(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "CMM_INSPECTION", enumSelectTool.ValueAsString)); } } }
public static extern bool DeviceSetElectrode(Electrode electrode);
/// <summary> /// This spawns the electrodes for the subject. /// </summary> /// <param name="subjectName">Subject name.</param> /// <param name="average_brain">If set to <c>true</c> average brain.</param> public override IEnumerator Spawn(string subjectName, bool average_brain = false) { subjects_to_electrodes.Add(subjectName, new List <Electrode> ()); subjects_enabled.Add(subjectName, true); CoroutineWithData getElectrodeCSVReader = new CoroutineWithData(this, GetElectrodeFileReader(subjectName, "electrode_coordinates.csv")); yield return(getElectrodeCSVReader.coroutine); System.IO.TextReader reader = (System.IO.TextReader)getElectrodeCSVReader.result; Dictionary <string, GameObject> atlasParents = new Dictionary <string, GameObject> (); Dictionary <string, Electrode> electrodes = new Dictionary <string, Electrode> (); reader.ReadLine(); //discard the first line, which contains column names string line; while ((line = reader.ReadLine()) != null) { string[] values = line.Split(','); string atlas = values [5]; if (average_brain && !atlas.Equals("avg.corrected")) { continue; } else if (!average_brain && !atlas.Equals("ind.corrected")) { continue; } GameObject indicator = Instantiate(electrodeIndicatorPrefab); Electrode electrode = indicator.GetComponent <Electrode> (); if (!atlasParents.ContainsKey(atlas)) { GameObject newAtlasParent = new GameObject(); newAtlasParent.transform.parent = gameObject.transform; newAtlasParent.name = atlas; atlasParents.Add(atlas, newAtlasParent); } electrode.Initialize ( subjectName, values[0], values[1], -float.Parse(values[2]) * 0.02f, //this is weirdly flipped float.Parse(values[3]) * 0.02f, //and these are all in wrong units, so must be scaled float.Parse(values[4]) * 0.02f, values[5], StandardizeElectrodeName(atlas, subjectName, values[6]) ); string standardized_name = StandardizeElectrodeName(atlas, subjectName, values [0]); if (!electrodes.ContainsKey(standardized_name)) { electrodes.Add(standardized_name, electrode); } else { Destroy(indicator); continue; } subjects_to_electrodes [subjectName].Add(electrode); indicator.transform.parent = atlasParents[atlas].transform; electrode.SetSMEValues ( float.Parse(values [10]), float.Parse(values [9]), float.Parse(values [8]), float.Parse(values [7]) ); } ///////orientation and micro detection//////// List <GameObject> micros = new List <GameObject>(); foreach (Electrode orientMe in electrodes.Values) { List <Collider> nearbies = new List <Collider>(Physics.OverlapSphere(orientMe.transform.position, NEARBY_THRESHHOLD)); List <Collider> too_close = new List <Collider>(Physics.OverlapSphere(orientMe.transform.position, TOO_CLOSE)); List <Collider> remove_us = new List <Collider> (); foreach (Collider too_close_colider in too_close) { remove_us.Add(too_close_colider); } foreach (Collider nearbie in nearbies) { if (!nearbie.tag.Equals("electrode")) { remove_us.Add(nearbie); } } foreach (Collider too_close_collider in remove_us) { nearbies.Remove(too_close_collider); } if (electrodes.ContainsKey(orientMe.GetOrientTo())) { orientMe.gameObject.transform.LookAt(electrodes [orientMe.GetOrientTo()].transform); } else { if (nearbies.Count > 0) { orientMe.gameObject.transform.LookAt(nearbies [0].transform.position); } } //point "S" and "G" towards the center of the brain if (orientMe.GetContactType().Contains("G") || orientMe.GetContactType().Contains("S")) { orientMe.transform.LookAt(gameObject.transform); } orientMe.transform.Rotate(new Vector3(90, 0, 0)); //////these are micros if (too_close.Count > MICRO_CLUSTER_THRESHHOLD) { orientMe.MarkMicro(); micros.Add(orientMe.gameObject); } } foreach (GameObject micro in micros) { micro.transform.position = micro.transform.position + new Vector3(Random.Range(-MICRO_JITTER, MICRO_JITTER), Random.Range(-MICRO_JITTER, MICRO_JITTER), Random.Range(-MICRO_JITTER, MICRO_JITTER)); micro.transform.localScale = micro.transform.localScale * MICRO_SHRINK; micro.GetComponent <Renderer> ().material.color = Color.black; } }
public List <List <Electrode> > Process() { var listReturn = new List <List <Electrode> >(); //获取奇数电极和偶数电极集合 var oddList = new List <Electrode>(); var evenList = new List <Electrode>(); _list.ForEach(pole => { if (pole.IdCurrent % 2 == 0) { evenList.Add(pole); } else if (pole.IdCurrent % 2 == 1) { oddList.Add(pole); } else { throw new Exception("电极当前值异常"); } }); //遍历奇数集合和偶数集合 oddList.ForEach(oddPole => { evenList.ForEach(evenPole => { //获得A,B,M的值 var oddNum = oddPole.IdCurrent; var evenNum = evenPole.IdCurrent; var mNum = SelectElectrodeM(oddNum, evenNum, _list[_list.Count - 1].IdCurrent); Electrode a = null; Electrode b = null; Electrode m = null; //根据A,B,M的值得到电极 _list.ForEach(pole => { if (pole.IdCurrent == oddNum) { a = pole.Clone(PoleMode.A); } if (pole.IdCurrent == evenNum) { b = pole.Clone(PoleMode.B); } if (pole.IdCurrent == mNum) { m = pole.Clone(PoleMode.M); } }); if ((a == null) || ((b == null) | (m == null))) { throw new Exception(); } var listFinal = new List <Electrode>(3) { a, b, m }; listReturn.Add(listFinal); }); }); return(listReturn); }