├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── LICENSE ├── README.md ├── analysis ├── analyse_nodal_singularity_occupancy.m ├── calculate_energy_grid.m ├── calculate_energy_nodal.m ├── calculate_kinetic_energy.m ├── cohcorrgram.m ├── compute_cohcorrgram_dwelltimes.m ├── corrgram.m ├── dbscan.m ├── energy_states.m ├── extract_energy_dwelltimes.m ├── extractbursts.m ├── main_analysis.m ├── perform_svd.m ├── spatial_xcorr.m ├── step_nodal_singularity_occupancy.m └── svd_3d.m ├── bin └── bash │ └── run_multiple_jobs_3d_flows_dracarys.sh ├── core ├── data3d_boundary_mask_inner.m ├── data3d_boundary_mask_outter_between.m ├── data3d_calculate_boundary_masks.m ├── data3d_get_interpolation_meshgrid.m ├── data3d_interpolate.m ├── data3d_interpolate_parallel.m ├── data3d_interpolate_serial.m ├── flows3d_cnem_amplitude.m ├── flows3d_cnem_calculate_partial_derivatives.m ├── flows3d_cnem_estimate.m ├── flows3d_cnem_get_B_mat.m ├── flows3d_cnem_grad_V.m ├── flows3d_cnem_phase.m ├── flows3d_cnem_phase_legacy.m ├── flows3d_cnem_set_initial_flows.m ├── flows3d_cnem_step.m ├── flows3d_detect_null_flow_field.m ├── flows3d_get_unstructured_flows_parallel.m ├── flows3d_hs3d_calculate_partial_derivatives.m ├── flows3d_hs3d_estimate.m ├── flows3d_hs3d_loop.m ├── flows3d_hs3d_set_initial_flows.m ├── flows3d_hs3d_step.m ├── main_core.m ├── singularity3d_classify.m ├── singularity3d_classify_critical_points.m ├── singularity3d_classify_orbits.m ├── singularity3d_classify_parallel.m ├── singularity3d_classify_serial.m ├── singularity3d_count.m ├── singularity3d_detect.m ├── singularity3d_jacobian.m ├── singularity3d_track.m ├── streams3d_clusters.m ├── streams3d_pathlines_cnem.m ├── streams3d_trace.m ├── streams3d_tracing_cnem.m ├── streams3d_tracing_cnem_legacy.m ├── streams3d_tracing_mlab_parallel.m └── streams3d_tracing_mlab_serial.m ├── demo-data ├── 513COG.mat ├── 513COG_lr.mat ├── convex_hull_bh_lh_rh_513parc_free_boundary_projections.mat ├── fmri_waves_unstructured_single_subject_20_short.mat ├── img │ ├── fig_rotating_wave_svd.png │ ├── fig_sing_tracking.png │ ├── fig_summary_stats.png │ └── fig_workflow_pretty_vis.png ├── neural_flows_cortex_mesh.mat ├── rotating_wave_W_c1_d1ms_iomat.mat ├── rotating_wave_W_c1_d1ms_trial1.mat ├── sink-source_wave_W_c1_d1ms_trial1.mat ├── travelling-cp_wave_W_c1_d1ms_trial1.mat └── travelling_wave_W_c1_d1ms_trial1.mat ├── examples ├── configs │ ├── fmri-waves_unstructured-amplitude-hs-meshbased_input.json │ ├── rotating-wave_unstructured-amplitude-hs-meshbased_input.json │ ├── rotating-wave_unstructured-amplitude-hs-meshless_input.json │ ├── rotating-wave_unstructured-phase-pg-meshless_input.json │ ├── sink-source-wave_unstructured-amplitude-hs-meshbased_input.json │ ├── sink-source-wave_unstructured-amplitude-hs-meshless_input.json │ ├── sink-source-wave_unstructured_phase-pg-meshless_input.json │ ├── travelling-reflected-wave_unstructured-amplitude-hs-meshbased_input.json │ └── travelling-reflected-wave_unstructured-amplitude-hs-meshless_input.json ├── fmri_waves.m ├── fmri_waves_movies.m ├── rotating_wave.m ├── sink_source_wave.m └── travelling_reflected_wave.m ├── external ├── cnem_03-10-17 │ ├── 2018-11-24_amran_illoul_instructions.txt │ ├── COPYING │ ├── COPYING.LESSER │ ├── README │ ├── matlab │ │ ├── bin │ │ │ ├── bbox_005 │ │ │ ├── bbox_01 │ │ │ ├── bbox_02 │ │ │ ├── bbox_03 │ │ │ ├── cal_B_Mat.m │ │ │ ├── cal_B_Mat_gen.m │ │ │ ├── cal_B_Mat_hydrodyn.m │ │ │ ├── cal_B_Mat_hydrodyn_axi.m │ │ │ ├── cal_B_Mat_hydrodyn_axi_pre.m │ │ │ ├── cal_B_Mat_meca.m │ │ │ ├── cal_B_Mat_therm.m │ │ │ ├── cal_Behav_Mat_hydrodyn.m │ │ │ ├── cal_Behav_Mat_hydrodyn_axi.m │ │ │ ├── cal_Behav_Mat_meca.m │ │ │ ├── cal_Behav_Mat_therm.m │ │ │ ├── cal_M_Mat_HD_scni.m │ │ │ ├── cal_M_Mat_TH_scni.m │ │ │ ├── cal_Mat_Vec.m │ │ │ ├── cal_Vol_Mat.m │ │ │ ├── cnem3d.mexa64 │ │ │ ├── m_assembling_gen.m │ │ │ ├── m_assembling_hydrodyn.m │ │ │ ├── m_assembling_hydrodyn_axi.m │ │ │ ├── m_assembling_meca.m │ │ │ ├── m_assembling_thermal.m │ │ │ ├── m_cnem2d_gauss.m │ │ │ ├── m_cnem2d_interpol.m │ │ │ ├── m_cnem2d_mesh.m │ │ │ ├── m_cnem2d_scni.m │ │ │ ├── m_cnem2d_scni_axi.m │ │ │ ├── m_cnem3d_SibsonRaw.m │ │ │ ├── m_cnem3d_interpol.m │ │ │ ├── m_cnem3d_mesh.m │ │ │ ├── m_cnem3d_scni.m │ │ │ ├── plot_bord_and_node.m │ │ │ ├── plot_boundary.m │ │ │ ├── plot_cel_vc.m │ │ │ ├── sparse_block.m │ │ │ ├── test_script.m │ │ │ └── tet │ │ ├── libbuild │ │ │ ├── make_cnem2d.m │ │ │ ├── make_cnem3d.m │ │ │ ├── make_mex_func.m │ │ │ ├── make_tet │ │ │ └── make_tet.bat │ │ ├── tuto2d │ │ │ ├── TriStream.m │ │ │ ├── exmple_mesh.m │ │ │ ├── f_bord_func.m │ │ │ ├── int_f_bord.m │ │ │ ├── tricontour.m │ │ │ ├── tuto_gen2d.m │ │ │ ├── tuto_hydrodyn2d.m │ │ │ ├── tuto_interpol2d.m │ │ │ ├── tuto_meca2d.asv │ │ │ ├── tuto_meca2d.m │ │ │ ├── tuto_meca2d_bis.m │ │ │ ├── tuto_mesh2d.m │ │ │ ├── tuto_therm2d.asv │ │ │ └── tuto_therm2d.m │ │ └── tuto3d │ │ │ ├── out_var_vtk.m │ │ │ ├── tuto_SibsonRaw3d.m │ │ │ ├── tuto_hydrodyn3d.m │ │ │ ├── tuto_interpol3d.m │ │ │ ├── tuto_meca3d.m │ │ │ ├── tuto_meca3d_eig.m │ │ │ ├── tuto_meca3d_exp.m │ │ │ ├── tuto_mesh3d.m │ │ │ └── tuto_therm3d.m │ ├── python │ │ ├── bin │ │ │ ├── CNEM3D.cpython-37m-x86_64-linux-gnu.so │ │ │ ├── bbox_005 │ │ │ ├── bbox_01 │ │ │ ├── bbox_02 │ │ │ ├── bbox_03 │ │ │ ├── check_gs.py │ │ │ ├── py_assembling.py │ │ │ ├── py_cnem2d.py │ │ │ ├── py_cnem3d.py │ │ │ └── tet │ │ ├── libbuild │ │ │ ├── main_tetgen_exe.o │ │ │ ├── make_tet │ │ │ ├── make_tet.bat │ │ │ ├── predicates.o │ │ │ ├── setup_cnem2d.py │ │ │ ├── setup_cnem3d.py │ │ │ ├── temp │ │ │ │ └── home │ │ │ │ │ └── paula │ │ │ │ │ └── Work │ │ │ │ │ └── Code │ │ │ │ │ └── Matlab │ │ │ │ │ └── cnem_03-10-17 │ │ │ │ │ └── src │ │ │ │ │ └── TETGEN │ │ │ │ │ └── predicates.o │ │ │ └── tetgen.o │ │ └── tuto │ │ │ ├── bare │ │ │ ├── tri.dat │ │ │ └── xyz.dat │ │ │ ├── cubeuni3d │ │ │ ├── tri.dat │ │ │ └── xyz.dat │ │ │ ├── data2d_small │ │ │ ├── ind_nf.dat │ │ │ ├── nb_nf.dat │ │ │ └── xy.dat │ │ │ ├── data3d_small │ │ │ ├── tri.dat │ │ │ └── xyz.dat │ │ │ ├── load_node_front.py │ │ │ ├── outvar.py │ │ │ ├── tuto_gen2d.py │ │ │ ├── tuto_gen3d.py │ │ │ ├── tuto_hydrodyn2d.py │ │ │ ├── tuto_hydrodyn3d.py │ │ │ ├── tuto_interpol2d.py │ │ │ ├── tuto_interpol3d.py │ │ │ ├── tuto_meca2d.py │ │ │ ├── tuto_meca3d.py │ │ │ ├── tuto_meca3d_eig.py │ │ │ ├── tuto_meca3d_exp.py │ │ │ ├── tuto_thermal2d.py │ │ │ └── tuto_thermal3d.py │ └── src │ │ ├── CNEM2D │ │ ├── C_Cellule.cpp │ │ ├── C_Cellule.h │ │ ├── C_Meshless_2d.cpp │ │ ├── C_Meshless_2d.h │ │ ├── C_Pnt2d.cpp │ │ ├── C_Pnt2d.h │ │ ├── C_Vec2d.cpp │ │ ├── C_Vec2d.h │ │ ├── Global_Header.h │ │ ├── cnem2d_mex.cpp │ │ ├── cnem2d_py.cpp │ │ ├── gauss_cnem2d.cpp │ │ ├── gauss_cnem2d.h │ │ ├── interpol_cnem2d.cpp │ │ ├── interpol_cnem2d.h │ │ ├── mesh_cnem2d.cpp │ │ ├── mesh_cnem2d.h │ │ ├── scni_cnem2d.cpp │ │ └── scni_cnem2d.h │ │ ├── CNEM3D │ │ ├── C_Cellule.cpp │ │ ├── C_Cellule.h │ │ ├── C_Diag_Vor.cpp │ │ ├── C_Diag_Vor.h │ │ ├── C_Meshless_3d.h │ │ ├── C_Meshless_3d_C_Meshless_3d.cpp │ │ ├── C_Meshless_3d_DVC.cpp │ │ ├── C_Meshless_3d_IntNoeEsc.cpp │ │ ├── C_Meshless_3d_PntGau.cpp │ │ ├── C_Meshless_3d_Tri.cpp │ │ ├── C_Meshless_3d_Util.cpp │ │ ├── C_Meshless_3d_ff.cpp │ │ ├── C_Pnt3d.cpp │ │ ├── C_Pnt3d.h │ │ ├── C_Sommet.cpp │ │ ├── C_Sommet.h │ │ ├── C_Vec3d.cpp │ │ ├── C_Vec3d.h │ │ ├── Const_Top_Front.cpp │ │ ├── Const_Top_Front.h │ │ ├── Global_Header.h │ │ ├── GradStabParal.cpp │ │ ├── GradStabParal.h │ │ ├── Group_Tet.cpp │ │ ├── Groupe_Tet.h │ │ ├── InterpolParal.cpp │ │ ├── InterpolParal.h │ │ ├── cnem3d_mex.cpp │ │ ├── cnem3d_py.cpp │ │ ├── interpol_cnem3d.cpp │ │ ├── interpol_cnem3d.h │ │ ├── main_tetgen_exe.cpp │ │ ├── mesh_cnem3d.cpp │ │ ├── mesh_cnem3d.h │ │ ├── out_elem_celqt.cpp │ │ ├── out_elem_celqt.h │ │ ├── scni_cnem3d.cpp │ │ └── scni_cnem3d.h │ │ ├── TETGEN │ │ ├── LICENSE │ │ ├── README │ │ ├── example.poly │ │ ├── predicates.cpp │ │ ├── tetgen.cpp │ │ └── tetgen.h │ │ └── UTILE │ │ ├── mat_map.h │ │ ├── pnt_gauss_2d.cpp │ │ ├── pnt_gauss_2d.h │ │ ├── utile_py.cpp │ │ └── utile_py.h ├── color_line3 │ ├── color_line3.m │ └── license.txt ├── cprintf │ ├── cprintf.m │ └── license.txt ├── quiver3Dpatch │ ├── license.txt │ └── quiver3Dpatch.m ├── simpletracker │ ├── LICENSE │ ├── README.md │ ├── publish │ │ ├── TestSimpleTracker.m │ │ └── html │ │ │ └── TestSimpleTracker.html │ └── src │ │ ├── hungarianlinker.m │ │ ├── munkres.m │ │ ├── nearestneighborlinker.m │ │ └── simpletracker.m └── tight_subplot │ ├── license.txt │ └── tight_subplot.m ├── io ├── check_os.m ├── check_storage_dirs.m ├── create_iomat_file.m ├── generate_slice_filename.m ├── generate_temp_filename.m ├── get_directory_path.m ├── get_neural_flows_path.m ├── load_data.m ├── load_iomat_data.m ├── load_iomat_flows.m ├── load_iomat_interp.m ├── load_iomat_singularity.m ├── load_iomat_streams.m ├── open_parpool.m ├── read_write_json.m ├── save_params_checkpoint.m ├── savefast.m └── spmd_parfor_with_matfiles.m ├── startup.m ├── tests ├── configs │ ├── test-flow-planewave3d-scattered-in.json │ ├── test-flow-travellingbiwave3d-scattered-in.json │ ├── test-flow-travellingwave3d-grid-in.json │ ├── test-flows3d-estimation_biharmonic-wave_sah_in.json │ ├── test-flows3d-estimation_biharmonic-wave_uac_in.json │ ├── test-flows3d-estimation_biharmonic-wave_uah_in.json │ ├── test-flows3d-estimation_biharmonic-wave_upc_in.json │ ├── test-flows3d-estimation_plane-wave_sah_in.json │ ├── test-flows3d-estimation_plane-wave_uac_in.json │ ├── test-flows3d-estimation_plane-wave_uah_in.json │ ├── test-flows3d-estimation_plane-wave_upc_in.json │ ├── test-flows3d-estimation_travelling-wave_sah_in.json │ ├── test-flows3d-estimation_travelling-wave_uac_in.json │ ├── test-flows3d-estimation_travelling-wave_uah_in.json │ └── test-flows3d-estimation_travelling-wave_upc_in.json ├── data │ ├── data-biharmonic-wave-structured-iomat.mat │ ├── data-biharmonic-wave-unstructured-iomat.mat │ ├── data-biharmonic-wave-unstructured.mat │ ├── data-plane-wave-structured-iomat.mat │ ├── data-plane-wave-unstructured-iomat.mat │ ├── data-plane-wave-unstructured.mat │ ├── data-spiral-wave-structured-iomat.mat │ ├── data-spiral-wave-unstructured-iomat.mat │ ├── data-spiral-wave-unstructured.mat │ ├── data-travelling-wave-structured-iomat.mat │ ├── data-travelling-wave-unstructured-iomat.mat │ └── data-travelling-wave-unstructured.mat ├── generate │ ├── generate_data3d.m │ ├── generate_data3d_plane_wave.m │ ├── generate_data3d_spiral_wave.m │ ├── generate_data3d_travelling_biharmonic_wave.m │ ├── generate_data3d_travelling_wave.m │ ├── generate_flows3d_abc.m │ ├── generate_flows3d_abc_unsteady.m │ ├── generate_flows3d_burgesvortex.m │ ├── generate_flows3d_embeddedvortex.m │ └── generate_singularity3d_hyperbolic_critical_points.m ├── test_flows3d_estimation__plane_wave_sah.m ├── test_flows3d_estimation__plane_wave_uac.m ├── test_flows3d_estimation__plane_wave_uah.m ├── test_flows3d_estimation__plane_wave_upc.m ├── test_flows3d_estimation__spiral_wave_sah.m ├── test_flows3d_estimation__spiral_wave_uac.m ├── test_flows3d_estimation__spiral_wave_uah.m ├── test_flows3d_estimation__spiral_wave_upc.m ├── test_flows3d_estimation__travelling_biharmonic_wave_sah.m ├── test_flows3d_estimation__travelling_biharmonic_wave_uac.m ├── test_flows3d_estimation__travelling_biharmonic_wave_uah.m ├── test_flows3d_estimation__travelling_biharmonic_wave_upc.m ├── test_flows3d_estimation__travelling_wave_sah.m ├── test_flows3d_estimation__travelling_wave_uac.m ├── test_flows3d_estimation__travelling_wave_uah.m ├── test_flows3d_estimation__travelling_wave_upc.m ├── test_performance_rotating_wave.m ├── test_singularity3d_classification__hyperbolic_points.m └── test_singularity3d_detection__abc_flow.m ├── utils ├── calc │ ├── apply_spatiotemporal_mask.m │ ├── build_neighbour_matrix.m │ ├── calculate_energy_tess.m │ ├── dis.m │ ├── find_boundary_faces.m │ ├── find_locs_grid_idx.m │ ├── get_convex_hull.m │ ├── get_grid_limits.m │ ├── get_laplacian_kernel_3d.m │ ├── get_local_surface.m │ ├── get_nth_ring.m │ ├── get_nth_ring_matrix.m │ ├── get_seeding_locations.m │ ├── get_seeding_locations_2d_slice.m │ ├── get_seeding_locations_3d_slice.m │ ├── get_sobel_kernel_3d.m │ ├── get_structured_grid.m │ ├── get_triangle_barycenter.m │ ├── gradientxyz.m │ ├── guesstimate_nullflows_threshold.m │ ├── kinetic_energy.m │ ├── moore_neighbourhood_3d.m │ ├── nanconvn.m │ ├── normalise_vector_field.m │ ├── s3d_get_numlabel.m │ ├── s3d_str2num_label.m │ └── switch_index_mode.m ├── misc │ ├── display_info_banner.m │ ├── display_toolbox_name.m │ ├── s3d_get_base_singularity_list.m │ ├── tik.m │ └── tok.m ├── signal │ ├── bandpass_filter.m │ ├── calculate_insta_phase.m │ └── rfft.m └── vis │ ├── add_vertices.m │ ├── colour_wheel.m │ ├── colourmaps │ ├── bluegred.m │ ├── compute_circular_jet_hue.m │ ├── greenyellowred.m │ ├── inferno.m │ ├── magma.m │ ├── plasma.m │ ├── redyellowblue.m │ ├── redyellowwhiteblue.m │ └── viridis.m │ ├── export_fig.m │ ├── find_min_max.m │ ├── get_number_subplots.m │ ├── get_quantile_crange.m │ ├── get_set_options.m │ ├── hex2rgb.m │ ├── interpolated_colourmap.m │ ├── make_streams_uniform.m │ ├── print2array.m │ ├── s3d_get_colours.m │ ├── standardise_range.m │ └── using_hg2.m └── visualisation ├── convex_hull_lh_513parc.mat ├── convex_hull_lh_513parc_projections.mat ├── draw_stream_arrow.m ├── figure_surf.m ├── main_visualisation.m ├── make_movie_gif.m ├── p3_streamparticles.m ├── pcolor3.m ├── plot1d_flows_ts.m ├── plot1d_singularity_histograms.m ├── plot1d_singularity_relative_spatial_occupancy.m ├── plot1d_singularity_relative_temporal_occupancy.m ├── plot1d_singularity_sandplot.m ├── plot1d_singularity_sandplot_nodal.m ├── plot1d_singularity_stats.m ├── plot1d_singularity_traces_counts.m ├── plot1d_singularity_traces_sandplot.m ├── plot1d_speed_distribution.m ├── plot2d_cohcorrgram.m ├── plot2d_singularity_tracking_cross_stitch.m ├── plot2d_svd_modes.m ├── plot3d_debug_data_frame.m ├── plot3d_flow_frame.m ├── plot3d_flows_ts.m ├── plot3d_hyperbolic_critical_point.m ├── plot3d_nodal_streamlines.m ├── plot3d_pathlines.m ├── plot3d_pathlines_coloured.m ├── plot3d_pcolor3_movie.m ├── plot3d_singularity_temporal_occupancy.m ├── plot3d_streamparticles.m ├── plot_debug_boundary_masks.m ├── plot_debug_flow_histogram.m ├── plot_local_surface.m ├── plot_quiver_slice.m ├── plot_scatter_projections.m ├── plot_sphereanim.m ├── plot_surf.m ├── plot_surface_mesh.m ├── plot_svd_modes.m ├── plot_velocity_field.m ├── plot_velocity_polaraxes.m ├── plotcomp_singularity_absolute_occupancy.m ├── plotmov_flows.m ├── plotmov_streamparticles.m ├── streamparticlesMod.m └── vfield3.m /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. Debian, Manajaro, Mac OS, Windows] 28 | - Matlab version [e.g. 2018b] 29 | - Device specs (RAM, processor) 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # stubs directory 2 | dir_to_ignore/ 3 | 4 | # output data 5 | output_data/ 6 | 7 | # output data 8 | dev-scripts/ 9 | 10 | # graohic output 11 | image_frames/ 12 | 13 | # generic storage directory 14 | scratch/ 15 | 16 | 17 | # temp files 18 | *.asv 19 | *.m~ 20 | *.mat 21 | 22 | # graphic files 23 | *.jpeg 24 | *.jpg 25 | *.png 26 | *.tiff 27 | *.pdf 28 | *.svg 29 | *.fig 30 | -------------------------------------------------------------------------------- /analysis/calculate_energy_grid.m: -------------------------------------------------------------------------------- 1 | function [energy] = calculate_energy_grid(params, obj_flows) 2 | %Computation of kinetic energy. The kinetic energy is similar to the norm of the 3 | % vector field, but it emphasizes low ( val < 1) vs high energy states (val > 1) 4 | % ARGUMENTS: 5 | % obj_flows -- a Matfile handle or structure with similar fields 6 | % 7 | % OUTPUT: 8 | %% 9 | % energy.spatial_sum -- Displacement energy in the flow, 10 | % summed over space. 11 | % energy.spatial_average -- Average displacement enegy 12 | % REQUIRES: 13 | % 14 | % USAGE: 15 | %{ 16 | 17 | 18 | %} 19 | % 20 | % MODIFICATION HISTORY: 21 | % Paula Sanz-Leon, QIMR Berghofer 2018 22 | % 23 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 24 | tpts = params.flows.data.shape.t; 25 | 26 | % Probably best to iterate over time 27 | innies_idx = obj_flows.masks.innies == true; 28 | temp_energy(length(innies), tpts) = 0; 29 | 30 | parfor tt=1:tpts 31 | un = obj_flows.un(:, :, :, tt); 32 | temp_energy(:, tt) = kinetic_energy(un(innies_idx)); 33 | end 34 | % 35 | norm_sum_flow = sqrt(obj_flows.ux_sum.^2 + obj_flows.uy_sum.^2 + obj_flows.uz_sum.^2); 36 | energy.spatial_sum = nansum(temp_energy); 37 | energy.spatial_average = nanmean(temp_energy); 38 | energy.spatial_median = nanmedian(temp_energy); 39 | energy.component_sum_norm = kinetic_energy(norm_sum_flow); 40 | energy.component_sum_ux = kinetic_energy(obj_flows.ux_sum); 41 | energy.component_sum_uy = kinetic_energy(obj_flows.uy_sum); 42 | energy.component_sum_uz = kinetic_energy(obj_flows.uz_sum); 43 | end % end calculate_energy_grid() -------------------------------------------------------------------------------- /analysis/calculate_kinetic_energy.m: -------------------------------------------------------------------------------- 1 | function calculate_kinetic_energy(params) 2 | % TODOC: 3 | % Wrapper function to call appropriate low level functions 4 | % ARGUMENTS: 5 | % 6 | % 7 | % 8 | % REQUIRES: 9 | % 10 | % USAGE: 11 | %{ 12 | 13 | 14 | %} 15 | % 16 | % MODIFICATION HISTORY: 17 | % Paula Sanz-Leon, QIMR Berghofer 2020 18 | % 19 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 20 | 21 | switch params.flows.quantification.energy.modality 22 | case {"nodal", "unstructured"} 23 | energy_fun = @calculate_energy_nodal; 24 | case {"grid", "structured"} 25 | energy_fun = @calculate_energy_grid; 26 | case {"mesh", "triangulation", "tesselation", "surf"} 27 | energy_fun = @calculate_energy_surf; 28 | otherwise 29 | end 30 | 31 | obj_flows = load_iomat_flows(params); 32 | obj_flows.Properties.Writable = true; 33 | 34 | % Calculate stuff 35 | energy_struct = energy_fun(params, obj_flows); 36 | 37 | % Do some basic stuff to shocawcase kintic energy functions 38 | display_flag = 'true'; 39 | extrema_detection = 'peaks'; 40 | % TODO: TOFIX: use resolution and length of FLOWS/NOT DATA 41 | time_vec = params.data.resolution.ht:params.data.resolution.ht:params.flows.data.shape.t*params.data.resolution.ht; 42 | min_duration_stable_state = params.data.resolution.ht * 30; 43 | [stable, transient, stablePoints, transientPoints] = energy_states(energy_struct.component_sum_norm, time_vec, params.data.resolution.ht, min_duration_stable_state, extrema_detection, display_flag); 44 | 45 | 46 | % Save output 47 | obj_flows.kinetic_energy = energy_struct; 48 | 49 | 50 | end % end calculate_kinetic_energy() 51 | -------------------------------------------------------------------------------- /analysis/main_analysis.m: -------------------------------------------------------------------------------- 1 | function main_analysis(inparams) 2 | %% Wrapper function to perform basic analysis: 3 | % (1): flows: svd decomposition 4 | % (2): flows: energy quantification 5 | % (3): singularity: quantification 6 | 7 | display_info_banner(mfilename, 'STARTED ANALYSIS.', '#5c5393', false) 8 | 9 | % Tic 10 | tstart = tik(); 11 | 12 | % Copy structure 13 | %tmp_params = inparams; 14 | 15 | %---------------------------------DECOMPOSITION-------------------------% 16 | if inparams.flows.decomposition.svd.enabled 17 | % Check if we need to interpolate data 18 | perform_svd(inparams); 19 | end 20 | 21 | if inparams.flows.quantification.energy.enabled 22 | calculate_kinetic_energy(inparams); 23 | end 24 | %---------------------------SINGULARITY---------------------------------% 25 | if inparams.singularity.quantification.enabled 26 | analyse_nodal_singularity_occupancy(inparams); 27 | end 28 | % TODO: write output parameters if reequired 29 | 30 | % Toc 31 | tok(tstart, 'minutes'); 32 | display_info_banner(mfilename, 'FINISHED ANALYSIS.', '#5c5393', false) 33 | 34 | end % function main_analysis() 35 | -------------------------------------------------------------------------------- /analysis/perform_svd.m: -------------------------------------------------------------------------------- 1 | function perform_svd(params) 2 | % Performs singular vector decomposition of a vector field. 3 | % Plots most dominant spatial modes and their time series 4 | % 5 | % USAGE: 6 | %{ 7 | 8 | %} 9 | % AUTHOR: 10 | % Paula Sanz-Leon, QIMR Berghofer, 2020 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | 13 | % Load flows data 14 | 15 | svd_struct = svd_3d(params); 16 | obj_flows = load_iomat_flows(params); 17 | obj_flows.Properties.Writable = true; 18 | obj_flows.flow_modes = svd_struct; 19 | obj_flows.Properties.Writable = false; 20 | end % function perform_svd() 21 | -------------------------------------------------------------------------------- /analysis/step_nodal_singularity_occupancy.m: -------------------------------------------------------------------------------- 1 | function [tracking_3d_matrix, tracking_2d_matrix] = step_nodal_singularity_occupancy(singularity_classification_frame, singularity_locs, nodal_locs, num_base_sngs, dist_th) 2 | % Finds the singularity closest to each node 3 | % TODOC: Function to be invoked by a parfor 4 | 5 | num_nodes = size(nodal_locs, 1); 6 | tracking_3d_matrix(num_base_sngs, num_nodes) = 0; 7 | tracking_2d_matrix(num_nodes) = 0; 8 | idx = find(singularity_classification_frame <= num_base_sngs); 9 | base_sings_temp = singularity_classification_frame(idx); 10 | if ~isempty(idx) 11 | for nn=1:size(nodal_locs, 1) 12 | singularity_locs_struct = singularity_locs{1}; 13 | xyz_sings = [singularity_locs_struct.x(idx), singularity_locs_struct.y(idx), singularity_locs_struct.z(idx)]; 14 | for ss=1:length(idx) 15 | [val_dis, nn_idx] = min(dis(xyz_sings(ss), nodal_locs.')); 16 | if val_dis <= dist_th 17 | tracking_3d_matrix(base_sings_temp(ss), nn_idx) = 1; 18 | tracking_2d_matrix(nn_idx) = base_sings_temp(ss); 19 | end 20 | end 21 | 22 | end 23 | end 24 | end % function step_nodal_singularity_occupancy() 25 | -------------------------------------------------------------------------------- /bin/bash/run_multiple_jobs_3d_flows_dracarys.sh: -------------------------------------------------------------------------------- 1 | ##!/usr/bin/env bash 2 | #Author: Paula Sanz-Leon / QIMR 3 | 4 | ### Started Executing Program 5 | echo "This job has started on:" 6 | date 7 | echo "----------------" 8 | echo "Job running on: `hostname`" 9 | echo "in directory: `pwd`" 10 | echo "####################################################" 11 | 12 | CHUNKS=({26..2}9) 13 | # The variable chunk will be used to index the time slice in the dataset 14 | for IDX_CHUNK in "${CHUNKS[@]}" 15 | do 16 | export IDX_CHUNK 17 | NAME=job_${IDX_CHUNK} 18 | echo "Submitting chunk: ${NAME}" 19 | 20 | MATLAB_CMD="addpath(genpath('/home/paula/Work/Code/Networks/neural-flows'));idx_chunk=$IDX_CHUNK;cluster_neurosrv_multiple_jobs_calculate_3d_flows(idx_chunk); exit" 21 | matlab -nodesktop -nosplash -nodisplay -r "$MATLAB_CMD" 22 | echo "done." 23 | done 24 | 25 | ##### Finished Executing Program ##### 26 | echo "This job has finished on:" 27 | date 28 | 29 | ##### Exit successfully 30 | exit 0 31 | -------------------------------------------------------------------------------- /core/data3d_boundary_mask_outter_between.m: -------------------------------------------------------------------------------- 1 | function [outter_bdy_mask, diff_mask] = data3d_boundary_mask_outter_between(inner_bdy_mask, shift_steps) 2 | %% This function calculates the alpha shape of scattered points in 3D, defined in locs. 3 | % It also returns the in/out status of the query points xq, yq, zq with respect 4 | % to the 3D alpha shape; and, the list of triangles of the boundary/convex 5 | % hull that encloses all the scattered points defined in locs. 6 | % 7 | % ARGUMENTS: 8 | % in_bdy_mask -- 9 | % shift_steps -- 10 | % 11 | % OUTPUT: 12 | % in_bdy_mask -- a logical vector of size [number_query_points x 1] 13 | % with the status of the query points. 14 | % bdy -- a [number_of_triangles x 3] array with the indices 15 | % of the points in locs that make up the triangles of 16 | % the boundary. 17 | % 18 | % REQUIRES: 19 | % Matlab's polyfun toolbox 20 | % 21 | % USAGE: 22 | %{ 23 | 24 | %} 25 | % 26 | % AUTHOR: 27 | % Paula Sanz-Leon, QIMR Berghofer 2019-02 28 | 29 | if nargin < 2 30 | shift_steps = 1; 31 | end 32 | 33 | ydim = 1; 34 | xdim = 2; 35 | zdim = 3; 36 | 37 | outter_bdy_mask = inner_bdy_mask; 38 | outter_bdy_mask = outter_bdy_mask + circshift(outter_bdy_mask, shift_steps, xdim) + circshift(outter_bdy_mask, -shift_steps, xdim); 39 | outter_bdy_mask = outter_bdy_mask + circshift(outter_bdy_mask, shift_steps, ydim) + circshift(outter_bdy_mask, -shift_steps, ydim); 40 | outter_bdy_mask = outter_bdy_mask + circshift(outter_bdy_mask, shift_steps, zdim) + circshift(outter_bdy_mask, -shift_steps, zdim); 41 | outter_bdy_mask(outter_bdy_mask > 0) = 1; 42 | 43 | diff_mask = logical(outter_bdy_mask - inner_bdy_mask); 44 | outter_bdy_mask = logical(outter_bdy_mask); 45 | 46 | 47 | end % function data3d_data3d_boundary_mask_outter_between() 48 | -------------------------------------------------------------------------------- /core/data3d_calculate_boundary_masks.m: -------------------------------------------------------------------------------- 1 | function [masks, params] = data3d_calculate_boundary_masks(locs, X, Y, Z, params) 2 | % Alpha radius has to be adjusted depending on the location data 3 | % (mostly, granularity of parcellation). 4 | if isfield(params.interpolation.boundary, 'alpha_radius') 5 | bdy_alpha_radius = params.interpolation.boundary.alpha_radius; 6 | end 7 | 8 | % Get a mask with the gridded-points that are inside and outside the convex hull 9 | % NOTE: This mask underestimates the volume occupied by the scattered 10 | % points 11 | [mask_innies, mask_innies_triangles] = data3d_boundary_mask_inner(locs, X(:), Y(:), Z(:), bdy_alpha_radius); 12 | 13 | mask_innies = reshape(mask_innies, params.interpolation.data.shape.grid); 14 | % Get a mask that is slightly larger so we can define a shell with a thickness that will be 15 | % the boundary of our domain. 16 | [mask_outties, mask_betweenies] = data3d_boundary_mask_outter_between(mask_innies, ... 17 | params.interpolation.boundary.thickness); 18 | 19 | % Masks 20 | masks.innies = mask_innies; 21 | masks.innies_triangles = mask_innies_triangles; 22 | masks.outties = mask_outties; 23 | masks.betweenies = mask_betweenies; 24 | 25 | end % function data3d_define_boundary_masks() -------------------------------------------------------------------------------- /core/data3d_get_interpolation_meshgrid.m: -------------------------------------------------------------------------------- 1 | function [X, Y, Z, params] = data3d_get_interpolation_meshgrid(locs, params) 2 | 3 | % TODO: document 4 | 5 | hx = params.interpolation.resolution.hx; 6 | hy = params.interpolation.resolution.hy; 7 | hz = params.interpolation.resolution.hz; 8 | 9 | % Generate a structured grid 10 | % TODO: save this parameter somewhere 11 | scaling_factor = 1.05; % inflate locations a little bit, so the grids have enough blank space around the volume 12 | [X, Y, Z, grid_size] = get_structured_grid(scaling_factor*locs, hx, hy, hz); 13 | 14 | params.interpolation.x_lims = [min(X(:)) max(X(:))]; 15 | params.interpolation.y_lims = [min(Y(:)) max(Y(:))]; 16 | params.interpolation.z_lims = [min(Z(:)) max(Z(:))]; 17 | % Save size of grid for interpolated data 18 | params.interpolation.data.shape.grid = grid_size; 19 | params.interpolation.data.shape.x = params.interpolation.data.shape.grid(params.data.x_dim_mgrid); 20 | params.interpolation.data.shape.y = params.interpolation.data.shape.grid(params.data.y_dim_mgrid); 21 | params.interpolation.data.shape.z = params.interpolation.data.shape.grid(params.data.z_dim_mgrid); 22 | 23 | end % function data3d_get_interpolation_meshgrid() 24 | -------------------------------------------------------------------------------- /core/flows3d_cnem_calculate_partial_derivatives.m: -------------------------------------------------------------------------------- 1 | function [Ix, Iy, Iz, It] = flows3d_cnem_calculate_partial_derivatives(F1, F2, ht, B) 2 | % This fuction computes 3D+t partial derivatives between two 3D image frames, 3 | % and is meant to be used by the Horn-Schunck algotithm, except that it 4 | % uses cnem. 5 | % 6 | % ARGUMENTS: 7 | % F1, F2 -- two subsequent 2D arrays 8 | % ht -- a double with the time step size 9 | % B -- CNEM differential matrix 10 | % OUTPUT:eeee 11 | % Ix, Iy, Iz, It -- partial derivatives along X, Y, Z and T axes respectively 12 | % 13 | % AUTHOR: 14 | % Paula Sanz-Leon, QIMR Berghofer, April 2020 15 | % USAGE: 16 | %{ 17 | 18 | %} 19 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 20 | 21 | xdim = 1; 22 | ydim = 2; 23 | zdim = 3; 24 | % Spatial derivatives are computed as the average of 25 | % the two image/frame gradients along each direction, 26 | % thus the magic number 0.5 in front of Ix, Iy, Iz 27 | Ix = (0.5*(get_derivative(F1, xdim, B) + get_derivative(F2, xdim, B))); 28 | Iy = (0.5*(get_derivative(F1, ydim, B) + get_derivative(F2, ydim, B))); 29 | Iz = (0.5*(get_derivative(F1, zdim, B) + get_derivative(F2, zdim, B))); 30 | It = [(F1 - F2)/ht].'; 31 | 32 | end % flows3d_cnem_calculate_partial_derivatives() 33 | 34 | function I = get_derivative(F, dim, B) 35 | Ixyz = flows3d_cnem_grad_V(B, F.'); 36 | I = Ixyz(:, dim); 37 | end % function get_derivative() 38 | -------------------------------------------------------------------------------- /core/flows3d_cnem_get_B_mat.m: -------------------------------------------------------------------------------- 1 | function B = flows3d_cnem_get_B_mat(XYZ, IN_Tri_Ini) 2 | %% Calculate the matrix B for calculating the gradient \nabla V evaluated at 3 | % 3-D scattered points in matrix XYZ 4 | % 5 | % ARGUMENTS: 6 | % XYZ -- a 2D array of size [nnodes/channels/locs x 3] 7 | % with coodinates of points in 3D space. 8 | % IN_Tri_Ini -- a 2D array of size [num_faces x 3] with the 9 | % triangulation of the boundary nodes (of the convex 10 | % hull that contains all the points defined in XYZ) 11 | % 12 | % OUTPUT: 13 | % B -- Matrix B of size ??? x ??? 14 | % 15 | % REQUIRES: 16 | % CNEM: https://ff-m2p.cnrs.fr/projects/cnem/, which itself depends on 17 | % TBB: http://www.threadingbuildingblocks.org/ 18 | % m_cnem3d_scni() from cnem libary 19 | % cal_B_Mat() from cnem library 20 | % 21 | % USAGE: 22 | %{ 23 | % to calculate the gradient of V 24 | Grad_V = B*V; 25 | Grad_V_mat = reshape(Grad_V, 4, [])'; 26 | 27 | %} 28 | % 29 | % MODIFICATION HISTORY: 30 | % JA Roberts, QIMR Berghofer, 2018 31 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 32 | 33 | if nargin < 2 34 | IN_Tri_Ini=[]; 35 | end 36 | 37 | Sup_NN_GS = 0; 38 | % Type of face interpolation 39 | Type_FF = 0;% 0 -> Sibson, 1 -> Laplace, 2 -> Linear fem 40 | 41 | % Signature of function call 42 | %[GS, XYZ, ... 43 | % IN_Tri_Ini,IN_Tri,IN_Tet,INV_NN,PNV_NN,... 44 | % IN_New_Old,IN_Old_New] = m_cnem3d_scni(XYZ, IN_Tri_Ini, Type_FF, Sup_NN_GS); 45 | [GS, ~, ~, ~, ~, ~, ~, ~, ~] = m_cnem3d_scni(XYZ, IN_Tri_Ini, Type_FF, Sup_NN_GS); 46 | 47 | nb_var = 1; 48 | 49 | B = cal_B_Mat(GS, nb_var); 50 | % end function cnem_get_B_mat() 51 | -------------------------------------------------------------------------------- /core/flows3d_cnem_grad_V.m: -------------------------------------------------------------------------------- 1 | function nabla_V = flows3d_cnem_grad_V(B, V) 2 | % Calculates the gradient of V (\nabla V) evaluated at 3-D scattered points in array XYZ 3 | % 4 | % ARGUMENTS: 5 | % V -- the matrix (??) of (???) of size ??? x ???? 6 | % B -- assembled matrix 7 | % 8 | % OUTPUT: 9 | % nabla_V -- gradient of V 10 | % 11 | % REQUIRES: 12 | % CNEM: https://ff-m2p.cnrs.fr/projects/cnem/, which itself depends on 13 | % TBB: http://www.threadingbuildingblocks.org/ 14 | % 15 | % USAGE: 16 | %{ 17 | 18 | gradV = flows3d_cnem_grad_V(B, V); 19 | 20 | %} 21 | % 22 | % MODIFICATION HISTORY: 23 | % JA Roberts, QIMR Berghofer, 2018 24 | % Updated, documented by Paula Sanz-Leon -- QIMR 2019 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | 27 | % gradV = grad_cnem(XYZ,V,[IN_Tri_Ini]) 28 | % Gradient \nabla V evaluated at 3-D scattered points in matrix XYZ 29 | % 30 | % Alternatively, can call 31 | % gradV = grad_cnem(B,V); 32 | % to use a precalculated B matrix 33 | % 34 | % Uses CNEM. 35 | 36 | % JA Roberts, QIMR Berghofer, 2018 37 | 38 | Grad_V = B*V; 39 | 40 | Grad_V_mat = reshape(Grad_V,4,[]).'; 41 | nabla_V = Grad_V_mat(:,1:3); % 4th column is Gradient Operator 42 | 43 | end % funcion cnem_grad_V() 44 | -------------------------------------------------------------------------------- /core/flows3d_cnem_set_initial_flows.m: -------------------------------------------------------------------------------- 1 | function [uxo, uyo, uzo] = flows3d_cnem_set_initial_flows(num_nodes, seed) 2 | %% This function produces random initial conditions drawn from a uniform distribution 3 | % 4 | % ARGUMENTS: 5 | % - num_nodes -- an integer with the number of nodes in the 6 | % unstructured dataset. 7 | % - seed -- an integer for the random number generator 8 | % OUTPUT: 9 | % uxo, uyo, uxo -- 1D arrays with random velocity components along each of the 10 | % 3 orthogonal axes. 11 | % 12 | % AUTHOR: 13 | % Paula Sanz-Leon, QIMR Berghofer April 2020 14 | % USAGE: 15 | %{ 16 | 17 | %} 18 | % REFERENCES: 19 | 20 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 21 | 22 | rng(seed) 23 | a = -0.125; 24 | b = 0.125; 25 | uxo = a + (b-a).*rand([num_nodes, 1]); 26 | uyo = a + (b-a).*rand([num_nodes, 1]); 27 | uzo = a + (b-a).*rand([num_nodes, 1]); 28 | 29 | end %flows3d_cnem_get_initial_flows() 30 | -------------------------------------------------------------------------------- /core/flows3d_hs3d_set_initial_flows.m: -------------------------------------------------------------------------------- 1 | function [uxo, uyo, uzo] = flows3d_hs3d_set_initial_flows(grid_shape, nan_mask, seed) 2 | %% This function produces random initial conditions drawn from a uniform distribution 3 | % 4 | % ARGUMENTS: 5 | % - grid_shape -- a three element vector with the size of the grid 6 | % - nan_mask -- a 3D logical array with 'true' where elements are nans, elements outside boundaries 7 | % - seed -- an integer for the random number generator 8 | % OUTPUT: 9 | % uxo, uyo, uxo -- 3D arrays with rando velocity components along each of the 10 | % 3 orthogonal axes. 11 | % 12 | % AUTHOR: 13 | % Paula Sanz-Leon, QIMR Berghofer December 2018 14 | % USAGE: 15 | %{ 16 | 17 | %} 18 | % REFERENCES: 19 | 20 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 21 | 22 | rng(seed) 23 | a = -0.125; % TODO: make it optional parameter based on data stats 24 | b = 0.125; % TODO: make it optional parameter based on data stats 25 | uxo = a + (b-a).*rand(grid_shape); 26 | uyo = a + (b-a).*rand(grid_shape); 27 | uzo = a + (b-a).*rand(grid_shape); 28 | uxo(nan_mask) = NaN; 29 | uyo(nan_mask) = NaN; 30 | uzo(nan_mask) = NaN; 31 | 32 | end %flows3d_hs3d_get_initial_flows() 33 | -------------------------------------------------------------------------------- /core/singularity3d_count.m: -------------------------------------------------------------------------------- 1 | function singularity_count = singularity3d_count(classification_cell_num, base_singularity_num_list) 2 | % A wrapper function to count how many singularities of each type 3 | % we have in the input structure. 4 | % s3d_count_singularities 5 | % 6 | % ARGUMENTS: 7 | % classification_cell -- a cell array 8 | % 9 | % OUTPUT: 10 | % 11 | % -- 12 | % 13 | % REQUIRES: 14 | 15 | % 16 | % USAGE: 17 | %{ 18 | 19 | %} 20 | % 21 | 22 | 23 | [singularity_count, ~] = hist(classification_cell_num, base_singularity_num_list); 24 | 25 | 26 | end % singularity3d_count() 27 | -------------------------------------------------------------------------------- /core/streams3d_clusters.m: -------------------------------------------------------------------------------- 1 | function out=streams3d_clusters(s, opts) 2 | % cluststruct = streamlineclusters(s,opts) 3 | % dense clusters of points from streamlines, looking only at streamlines 4 | % longer than a minimum length, only taking a subset of points from the 5 | % end, and with params for determining which cluster (if any) these points 6 | % belong to. 7 | % 8 | % inputs: s - cell array of streamlines (each element is an N-by-3 matrix) 9 | % opts - options struct with fields (defaults shown): 10 | % dbscanminpts=10; % minimum number of points to be deemed a cluster 11 | % dbscaneps=6; % radius (in mm) for identifying clusters 12 | % minstreamlength=20; % minimum streamline length (want the ones that ran for a while) 13 | % taillen=5; % only count this many points at the end 14 | % AUTHOR: James A. Roberts, QIMRB 2017-2018 (original: streamscluster) 15 | % Paula Sanz-Leon, QIMRB, 2020 16 | 17 | if nargin<2 18 | dbscanminpts=10; % minimum number of points to be deemed a cluster 19 | dbscaneps=6; % radius (in mm) for identifying clusters 20 | minstreamlength=20; % minimum streamline length (want the ones that ran for a while) 21 | taillen=5; % only count this many points at the end 22 | else 23 | dbscanminpts=opts.dbscanminpts; 24 | dbscaneps=opts.dbscaneps; 25 | minstreamlength=opts.minstreamlength; 26 | taillen=opts.taillen; 27 | end 28 | 29 | slong=s(cellfun(@length,s)>=minstreamlength); 30 | slongtail=cellfun(@(x) x(end-(taillen-1):end,:),slong,'uniformoutput',false); 31 | slongtailcat=vertcat(slongtail{:}); 32 | [sclustLabel,~]=dbscan(slongtailcat,dbscanminpts,dbscaneps); 33 | 34 | out.sclustPoints=slongtailcat; 35 | out.sclustLabel=sclustLabel; 36 | 37 | end % function streams3d_clusters 38 | -------------------------------------------------------------------------------- /demo-data/513COG.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/demo-data/513COG.mat -------------------------------------------------------------------------------- /demo-data/513COG_lr.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/demo-data/513COG_lr.mat -------------------------------------------------------------------------------- /demo-data/convex_hull_bh_lh_rh_513parc_free_boundary_projections.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/demo-data/convex_hull_bh_lh_rh_513parc_free_boundary_projections.mat -------------------------------------------------------------------------------- /demo-data/fmri_waves_unstructured_single_subject_20_short.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/demo-data/fmri_waves_unstructured_single_subject_20_short.mat -------------------------------------------------------------------------------- /demo-data/img/fig_rotating_wave_svd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/demo-data/img/fig_rotating_wave_svd.png -------------------------------------------------------------------------------- /demo-data/img/fig_sing_tracking.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/demo-data/img/fig_sing_tracking.png -------------------------------------------------------------------------------- /demo-data/img/fig_summary_stats.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/demo-data/img/fig_summary_stats.png -------------------------------------------------------------------------------- /demo-data/img/fig_workflow_pretty_vis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/demo-data/img/fig_workflow_pretty_vis.png -------------------------------------------------------------------------------- /demo-data/neural_flows_cortex_mesh.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/demo-data/neural_flows_cortex_mesh.mat -------------------------------------------------------------------------------- /demo-data/rotating_wave_W_c1_d1ms_iomat.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/demo-data/rotating_wave_W_c1_d1ms_iomat.mat -------------------------------------------------------------------------------- /demo-data/rotating_wave_W_c1_d1ms_trial1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/demo-data/rotating_wave_W_c1_d1ms_trial1.mat -------------------------------------------------------------------------------- /demo-data/sink-source_wave_W_c1_d1ms_trial1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/demo-data/sink-source_wave_W_c1_d1ms_trial1.mat -------------------------------------------------------------------------------- /demo-data/travelling-cp_wave_W_c1_d1ms_trial1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/demo-data/travelling-cp_wave_W_c1_d1ms_trial1.mat -------------------------------------------------------------------------------- /demo-data/travelling_wave_W_c1_d1ms_trial1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/demo-data/travelling_wave_W_c1_d1ms_trial1.mat -------------------------------------------------------------------------------- /examples/fmri_waves_movies.m: -------------------------------------------------------------------------------- 1 | function fmri_waves_movies() 2 | % This function runs visualisation functions on 3 | % flow and stream data generated after running fmri_waves() 4 | 5 | % This is the json file that fmri_waves() generated. 6 | params_filename = 'fmri-waves_unstructured-amplitude-hs-meshbased_subject-20_output.json'; 7 | params_dir = 'examples/configs'; 8 | json_mode = 'read'; 9 | 10 | % Load options 11 | ouparams = read_write_json(params_filename, params_dir, json_mode); 12 | plotmov_streamparticles(ouparams, 'particles', 10); 13 | plotmov_streamparticles(ouparams, 'streamlines', 2); 14 | plotmov_flows(ouparams); 15 | 16 | end -------------------------------------------------------------------------------- /external/cnem_03-10-17/2018-11-24_amran_illoul_instructions.txt: -------------------------------------------------------------------------------- 1 | -a) Rebuild all the library -- PSL: for linux systems with 64, make sure you have mutilib isntalled for 32 architecture 2 | 3 | -b) go to python\libbuild and run : make -f make_tet 4 | If matlab go to matlab\libbluid and do the same 5 | 6 | -c) Go to python\bin\py_cnem3d.py, line 39, 147, and 184 : and set Type_Call_Tet=1 7 | 8 | -d) Go to matlab\bin\m_cnem3d_scni.m line 26 and set Type_Call_Tet=1; 9 | m_cnem3d_interpol.m line 32 and set Type_Call_Tet=1; 10 | m_cnem3d_mesh.m line 26 and set Type_Call_Tet=1; -------------------------------------------------------------------------------- /external/cnem_03-10-17/README: -------------------------------------------------------------------------------- 1 | please go to http://plateformesn-m2p.ensam.eu/SphinxDoc/cnem/index.html for documentation -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/bbox_005: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/external/cnem_03-10-17/matlab/bin/bbox_005 -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/bbox_01: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/external/cnem_03-10-17/matlab/bin/bbox_01 -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/bbox_02: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/external/cnem_03-10-17/matlab/bin/bbox_02 -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/bbox_03: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/external/cnem_03-10-17/matlab/bin/bbox_03 -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/cal_B_Mat.m: -------------------------------------------------------------------------------- 1 | % Copyright (C) 2003-2011 2 | % Lounes ILLOUL (illoul_lounes@yahoo.fr) 3 | % Philippe LORONG (philippe.lorong@ensam.eu) 4 | % Arts et Metiers ParisTech, Paris, France 5 | 6 | function B = cal_B_Mat(GS,nb_var) 7 | 8 | Nb_V=GS.Nb_V; 9 | Ind_V=GS.Ind_V; 10 | Grad=GS.Grad; 11 | Dim=size(Grad,1); 12 | n=size(Nb_V,2); 13 | 14 | nb_val=(Dim*sum(Nb_V)+n)*nb_var; 15 | I_B=zeros(1,nb_val); 16 | J_B=zeros(1,nb_val); 17 | V_B=zeros(1,nb_val); 18 | 19 | L=1; 20 | L_bis=1; 21 | 22 | if Dim==2 23 | for i=1:n 24 | nb_val_i=2*Nb_V(i)+1; 25 | J=Ind_V(L:L+Nb_V(i)-1)+1; 26 | bx=Grad(1,L:L+Nb_V(i)-1); 27 | by=Grad(2,L:L+Nb_V(i)-1); 28 | L=L+Nb_V(i); 29 | for j=1:nb_var 30 | k=nb_var*(i-1)+j; 31 | I=k*ones(1,Nb_V(i)); 32 | I_B(L_bis:nb_val_i+L_bis-1)=[3*(I-1)+1,3*(I-1)+2,3*k]; 33 | J_B(L_bis:nb_val_i+L_bis-1)=[nb_var*(J-1)+j,nb_var*(J-1)+j,nb_var*(i-1)+j]; 34 | V_B(L_bis:nb_val_i+L_bis-1)=[bx,by,1.]; 35 | L_bis=L_bis+nb_val_i; 36 | end 37 | end 38 | else 39 | for i=1:n 40 | nb_val_i=3*Nb_V(i)+1; 41 | J=Ind_V(L:L+Nb_V(i)-1)+1; 42 | bx=Grad(1,L:L+Nb_V(i)-1); 43 | by=Grad(2,L:L+Nb_V(i)-1); 44 | bz=Grad(3,L:L+Nb_V(i)-1); 45 | L=L+Nb_V(i); 46 | for j=1:nb_var 47 | k=nb_var*(i-1)+j; 48 | I=k*ones(1,Nb_V(i)); 49 | I_B(L_bis:nb_val_i+L_bis-1)=[4*(I-1)+1,4*(I-1)+2,4*(I-1)+3,4*k]; 50 | J_B(L_bis:nb_val_i+L_bis-1)=[nb_var*(J-1)+j,nb_var*(J-1)+j,nb_var*(J-1)+j,nb_var*(i-1)+j]; 51 | V_B(L_bis:nb_val_i+L_bis-1)=[bx,by,bz,1.]; 52 | L_bis=L_bis+nb_val_i; 53 | end 54 | end 55 | end 56 | 57 | B=sparse(I_B,J_B,V_B,nb_var*(Dim+1)*n,nb_var*n); 58 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/cal_B_Mat_gen.m: -------------------------------------------------------------------------------- 1 | % Copyright (C) 2003-2011 2 | % Lounes ILLOUL (illoul_lounes@yahoo.fr) 3 | % Philippe LORONG (philippe.lorong@ensam.eu) 4 | % Nicolas RANC 5 | % Arts et Metiers ParisTech, Paris, France 6 | 7 | function B_Gen=cal_B_Mat_gen(B,Mat_Var1_to_Var2) 8 | 9 | B_Gen=sparse_block(Mat_Var1_to_Var2,size(Mat_Var1_to_Var2,1),size(B,1)/size(Mat_Var1_to_Var2,2))*B; 10 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/cal_B_Mat_hydrodyn.m: -------------------------------------------------------------------------------- 1 | % Copyright (C) 2003-2011 2 | % Lounes ILLOUL (illoul_lounes@yahoo.fr) 3 | % Philippe LORONG (philippe.lorong@ensam.eu) 4 | % Arts et Metiers ParisTech, Paris, France 5 | 6 | function B_Th=cal_B_Mat_hydrodyn(B,Dim) 7 | 8 | if Dim==2 9 | 10 | Mat_Var1_to_Var2=[1. 0. 0. 0. 0. 0. 0. 0. 0. 11 | 0. 1. 0. 0. 0. 0. 0. 0. 0. 12 | 0. 0. 0. 1. 0. 0. 0. 0. 0. 13 | 0. 0. 0. 0. 1. 0. 0. 0. 0. 14 | 0. 0. 0. 0. 0. 0. 0. 0. 1.]; 15 | else 16 | Mat_Var1_to_Var2=[1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 17 | 0. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 18 | 0. 0. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 19 | 0. 0. 0. 0. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 20 | 0. 0. 0. 0. 0. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 21 | 0. 0. 0. 0. 0. 0. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 22 | 0. 0. 0. 0. 0. 0. 0. 0. 1. 0. 0. 0. 0. 0. 0. 0. 23 | 0. 0. 0. 0. 0. 0. 0. 0. 0. 1. 0. 0. 0. 0. 0. 0. 24 | 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 1. 0. 0. 0. 0. 0. 25 | 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 1.]; 26 | end 27 | 28 | B_Th=sparse_block(Mat_Var1_to_Var2,size(Mat_Var1_to_Var2,1),size(B,1)/size(Mat_Var1_to_Var2,2))*B; 29 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/cal_B_Mat_hydrodyn_axi.m: -------------------------------------------------------------------------------- 1 | % Copyright (C) 2003-2011 2 | % Lounes ILLOUL (illoul_lounes@yahoo.fr) 3 | % Philippe LORONG (philippe.lorong@ensam.eu) 4 | % Arts et Metiers ParisTech, Paris, France 5 | 6 | function B_Th=cal_B_Mat_hydrodyn_axi(B) 7 | 8 | Mat_Var1_to_Var2=[1. 0. 0. 0. 0. 0. 0. 0. 0. 9 | 0. 1. 0. 0. 0. 0. 0. 0. 0. 10 | 0. 0. 1. 0. 0. 0. 0. 0. 0. 11 | 0. 0. 0. 1. 0. 0. 0. 0. 0. 12 | 0. 0. 0. 0. 1. 0. 0. 0. 0. 13 | 0. 0. 0. 0. 0. 1. 0. 0. 0. 14 | 0. 0. 0. 0. 0. 0. 0. 0. 1.]; 15 | 16 | B_Th=sparse_block(Mat_Var1_to_Var2,size(Mat_Var1_to_Var2,1),size(B,1)/size(Mat_Var1_to_Var2,2))*B; 17 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/cal_B_Mat_meca.m: -------------------------------------------------------------------------------- 1 | % Copyright (C) 2003-2011 2 | % Lounes ILLOUL (illoul_lounes@yahoo.fr) 3 | % Philippe LORONG (philippe.lorong@ensam.eu) 4 | % Arts et Metiers ParisTech, Paris, France 5 | 6 | function B_M=cal_B_Mat_meca(B,Dim) 7 | 8 | if Dim==2 9 | Mat_Var1_to_Var2=[1. 0. 0. 0. 0. 0. 10 | 0. 0. 0. 0. 1. 0. 11 | 0. 1. 0. 1. 0. 0.]; 12 | else 13 | Mat_Var1_to_Var2=[1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 14 | 0. 0. 0. 0. 0. 1. 0. 0. 0. 0. 0. 0. 15 | 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 1. 0. 16 | 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0. 17 | 0. 0. 1. 0. 0. 0. 0. 0. 1. 0. 0. 0. 18 | 0. 1. 0. 0. 1. 0. 0. 0. 0. 0. 0. 0.]; 19 | end 20 | 21 | B_M=sparse_block(Mat_Var1_to_Var2,size(Mat_Var1_to_Var2,1),size(B,1)/size(Mat_Var1_to_Var2,2))*B; 22 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/cal_B_Mat_therm.m: -------------------------------------------------------------------------------- 1 | % Copyright (C) 2003-2011 2 | % Lounes ILLOUL (illoul_lounes@yahoo.fr) 3 | % Philippe LORONG (philippe.lorong@ensam.eu) 4 | % Arts et Metiers ParisTech, Paris, France 5 | 6 | function B_Th=cal_B_Mat_therm(B,Dim) 7 | 8 | if Dim==2 9 | 10 | Mat_Var1_to_Var2=[1. 0. 0. 11 | 0. 1. 0.]; 12 | else 13 | Mat_Var1_to_Var2=[1. 0. 0. 0. 14 | 0. 1. 0. 0. 15 | 0. 0. 1. 0.]; 16 | end 17 | 18 | B_Th=sparse_block(Mat_Var1_to_Var2,size(Mat_Var1_to_Var2,1),size(B,1)/size(Mat_Var1_to_Var2,2))*B; 19 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/cal_Behav_Mat_hydrodyn.m: -------------------------------------------------------------------------------- 1 | % Copyright (C) 2003-2011 2 | % Lounes ILLOUL (illoul_lounes@yahoo.fr) 3 | % Philippe LORONG (philippe.lorong@ensam.eu) 4 | % Arts et Metiers ParisTech, Paris, France 5 | 6 | function Behav=cal_Behav_Mat_hydrodyn(NU,n,dim) 7 | 8 | n_bis=size(NU,1); 9 | 10 | PP_couple=0;%mean(NU)*eps; 11 | 12 | if dim==2 13 | Behav=zeros(5*n_bis,5); 14 | for i=1:n_bis 15 | Behav(5*(i-1)+1:5*i,:)=[2*NU(i) 0. 0. 0. -1. 16 | 0. NU(i) NU(i) 0. 0. 17 | 0. NU(i) NU(i) 0. 0. 18 | 0. 0. 0. 2*NU(i) -1. 19 | -1. 0. 0. -1. PP_couple]; 20 | end 21 | else 22 | Behav=zeros(10*n_bis,10); 23 | for i=1:n_bis 24 | Behav(10*(i-1)+1:10*i,:)=[2*NU(i) 0. 0. 0. 0. 0. 0. 0. 0. -1. 25 | 0. NU(i) 0. NU(i) 0. 0. 0. 0. 0. 0. 26 | 0. 0. NU(i) 0. 0. 0. NU(i) 0. 0. 0. 27 | 0. NU(i) 0. NU(i) 0. 0. 0. 0. 0. 0. 28 | 0. 0. 0. 0. 2*NU(i) 0. 0. 0. 0. -1. 29 | 0. 0. 0. 0. 0. NU(i) 0. NU(i) 0. 0. 30 | 0. 0. NU(i) 0. 0. 0. NU(i) 0. 0. 0. 31 | 0. 0. 0. 0. 0. NU(i) 0. NU(i) 0. 0. 32 | 0. 0. 0. 0. 0. 0. 0. 0. 2*NU(i) -1 33 | -1. 0. 0. 0. -1. 0. 0. 0. -1. PP_couple]; 34 | end 35 | end 36 | 37 | Behav=sparse_block(Behav,size(Behav,2),n); 38 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/cal_Behav_Mat_hydrodyn_axi.m: -------------------------------------------------------------------------------- 1 | % Copyright (C) 2003-2011 2 | % Lounes ILLOUL (illoul_lounes@yahoo.fr) 3 | % Philippe LORONG (philippe.lorong@ensam.eu) 4 | % Arts et Metiers ParisTech, Paris, France 5 | 6 | function Behav=cal_Behav_Mat_hydrodyn_axi(NU,n,r) 7 | 8 | PP_couple=0;%mean(NU)*eps; 9 | 10 | Behav=zeros(7*n,7); 11 | for i=1:n 12 | if size(NU,1)==n 13 | NU_i=NU(i); 14 | else 15 | NU_i=NU; 16 | end 17 | Behav(7*(i-1)+1:7*i,:)=[2*NU_i 0. 0. 0. 0. 0. -1. 18 | 0. NU_i 0. NU_i 0. 0. 0. 19 | 0. 0. 2*NU_i /(r(i)*r(i)) 0. 0. 0. -1/r(i) 20 | 0. NU_i 0. NU_i 0. 0. 0. 21 | 0. 0. 0. 0. 2*NU_i 0. -1. 22 | 0. 0. 0. 0. 0. 0. 0. 23 | -1. 0. -1/r(i) 0. -1. 0. PP_couple]; 24 | end 25 | 26 | Behav=sparse_block(Behav,size(Behav,2),n); 27 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/cal_Behav_Mat_meca.m: -------------------------------------------------------------------------------- 1 | % Copyright (C) 2003-2011 2 | % Lounes ILLOUL (illoul_lounes@yahoo.fr) 3 | % Philippe LORONG (philippe.lorong@ensam.eu) 4 | % Arts et Metiers ParisTech, Paris, France 5 | 6 | function Behav=cal_Behav_Mat_meca(E_NU,n,dim) 7 | 8 | if dim==2 9 | Behav=zeros(3*n,3); 10 | for i=1:n 11 | 12 | if size(E_NU,1)==1 13 | e_nu=E_NU; 14 | else 15 | e_nu=E_NU(i,:); 16 | end 17 | 18 | A=(1-e_nu(2))*e_nu(1)/((1+e_nu(2))*(1-2*e_nu(2))); 19 | B=e_nu(2)*e_nu(1)/((1+e_nu(2))*(1-2*e_nu(2))); 20 | C=(A-B)/2; 21 | 22 | Behav(3*(i-1)+1:3*i,:)=[A B 0. 23 | B A 0. 24 | 0. 0. C]; 25 | end 26 | else 27 | Behav=zeros(6*n,6); 28 | for i=1:n 29 | 30 | if size(E_NU,1)==1 31 | e_nu=E_NU; 32 | else 33 | e_nu=E_NU(i,:); 34 | end 35 | 36 | A=(1-e_nu(2))*e_nu(1)/((1+e_nu(2))*(1-2*e_nu(2))); 37 | B=e_nu(2)*e_nu(1)/((1+e_nu(2))*(1-2*e_nu(2))); 38 | C=(A-B)/2; 39 | 40 | Behav(6*(i-1)+1:6*i,:)=[A B B 0. 0. 0. 41 | B A B 0. 0. 0. 42 | B B A 0. 0. 0. 43 | 0. 0. 0. C 0. 0. 44 | 0. 0. 0. 0. C 0. 45 | 0. 0. 0. 0. 0. C]; 46 | end 47 | end 48 | 49 | Behav=sparse_block(Behav,size(Behav,2),n); 50 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/cal_Behav_Mat_therm.m: -------------------------------------------------------------------------------- 1 | % Copyright (C) 2003-2011 2 | % Lounes ILLOUL (illoul_lounes@yahoo.fr) 3 | % Philippe LORONG (philippe.lorong@ensam.eu) 4 | % Arts et Metiers ParisTech, Paris, France 5 | 6 | function Behav=cal_Behav_Mat_therm(K,n,dim) 7 | 8 | n_bis=size(K,1); 9 | 10 | if dim==2 11 | Behav=zeros(2*n_bis,2); 12 | for i=1:n_bis 13 | Behav(2*(i-1)+1:2*i,:)=[K(i) 0 14 | 0 K(i)]; 15 | end 16 | else 17 | Behav=zeros(3*n_bis,3); 18 | for i=1:n_bis 19 | Behav(3*(i-1)+1:3*i,:)=[K(i) 0. 0. 20 | 0. K(i) 0. 21 | 0. 0. K(i)]; 22 | end 23 | end 24 | 25 | Behav=sparse_block(Behav,size(Behav,2),n); 26 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/cal_M_Mat_HD_scni.m: -------------------------------------------------------------------------------- 1 | % Copyright (C) 2003-2011 2 | % Lounes ILLOUL (illoul_lounes@yahoo.fr) 3 | % Philippe LORONG (philippe.lorong@ensam.eu) 4 | % Arts et Metiers ParisTech, Paris, France 5 | 6 | function Mat=cal_M_Mat_HD_scni(GS,Ro) 7 | 8 | Mat=cal_Mat_Vec(Ro.*GS.Vol_C',[1;1;0]); -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/cal_M_Mat_TH_scni.m: -------------------------------------------------------------------------------- 1 | % Copyright (C) 2003-2011 2 | % Lounes ILLOUL (illoul_lounes@yahoo.fr) 3 | % Philippe LORONG (philippe.lorong@ensam.eu) 4 | % Arts et Metiers ParisTech, Paris, France 5 | 6 | function M=cal_M_Mat_TH_scni(GS,Ro,Cap) 7 | 8 | M=cal_Mat_Vec(Ro.*Cap.*GS.Vol_C',[1]); 9 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/cal_Mat_Vec.m: -------------------------------------------------------------------------------- 1 | % Copyright (C) 2003-2011 2 | % Lounes ILLOUL (illoul_lounes@yahoo.fr) 3 | % Philippe LORONG (philippe.lorong@ensam.eu) 4 | % Arts et Metiers ParisTech, Paris, France 5 | 6 | function Mat=cal_Mat_Vec(Vec,coef) 7 | 8 | n=size(Vec,1); 9 | rep=size(coef,1); 10 | Mat=zeros(rep*n,1); 11 | for i=1:rep 12 | Mat(i:rep:rep*n,1)=coef(i)*Vec; 13 | end 14 | Mat=spdiags(Mat,0,rep*n,rep*n); 15 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/cal_Vol_Mat.m: -------------------------------------------------------------------------------- 1 | % Copyright (C) 2003-2011 2 | % Lounes ILLOUL (illoul_lounes@yahoo.fr) 3 | % Philippe LORONG (philippe.lorong@ensam.eu) 4 | % Arts et Metiers ParisTech, Paris, France 5 | 6 | function Mat=cal_Vol_Mat(GS,rep) 7 | 8 | Vec=GS.Vol_C'; 9 | n=size(Vec,1); 10 | Mat=zeros(rep*n,1); 11 | for i=1:rep 12 | Mat(i:rep:rep*n,1)=Vec; 13 | end 14 | Mat=spdiags(Mat,0,rep*n,rep*n); 15 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/cnem3d.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/external/cnem_03-10-17/matlab/bin/cnem3d.mexa64 -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/m_assembling_gen.m: -------------------------------------------------------------------------------- 1 | % Copyright (C) 2003-2011 2 | % Lounes ILLOUL (illoul_lounes@yahoo.fr) 3 | % Philippe LORONG (philippe.lorong@ensam.eu) 4 | % Arts et Metiers ParisTech, Paris, France 5 | 6 | function [B,C,V]= m_assembling_gen(GS,Mat_Vars,Mat_Couple) 7 | 8 | n=size(GS.Vol_C,2); 9 | dim=size(GS.Grad,1); 10 | nb_var=size(Mat_Vars,2)/(dim+1); 11 | 12 | B=cal_B_Mat_gen(cal_B_Mat(GS,nb_var),Mat_Vars); 13 | C=sparse_block(Mat_Couple,size(Mat_Couple,2),n); 14 | V=cal_Mat_Vec(GS.Vol_C',ones(size(B,1)/n,1)); 15 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/m_assembling_hydrodyn.m: -------------------------------------------------------------------------------- 1 | % Copyright (C) 2003-2011 2 | % Lounes ILLOUL (illoul_lounes@yahoo.fr) 3 | % Philippe LORONG (philippe.lorong@ensam.eu) 4 | % Arts et Metiers ParisTech, Paris, France 5 | 6 | function [B,C,V]= m_assembling_hydrodyn(GS,NU) 7 | 8 | n=size(GS.Vol_C,2); 9 | dim=size(GS.Grad,1); 10 | nb_var=dim+1; 11 | 12 | B=cal_B_Mat_hydrodyn(cal_B_Mat(GS,nb_var),dim); 13 | C=cal_Behav_Mat_hydrodyn(NU,n,dim); 14 | V=cal_Mat_Vec(GS.Vol_C',ones(size(B,1)/n,1)); 15 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/m_assembling_hydrodyn_axi.m: -------------------------------------------------------------------------------- 1 | % Copyright (C) 2003-2011 2 | % Lounes ILLOUL (illoul_lounes@yahoo.fr) 3 | % Philippe LORONG (philippe.lorong@ensam.eu) 4 | % Arts et Metiers ParisTech, Paris, France 5 | 6 | function [B,C,V]= m_assembling_hydrodyn_axi(GS,NU) 7 | 8 | n=size(GS.Vol_C,2); 9 | nb_var=3; 10 | 11 | B=cal_B_Mat_hydrodyn_axi_pre(GS,nb_var); 12 | B=cal_B_Mat_hydrodyn_axi(B); 13 | C=cal_Behav_Mat_hydrodyn_axi(NU,n,GS.r); 14 | V=cal_Mat_Vec(GS.Vol_C',ones(size(B,1)/n,1)); 15 | 16 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/m_assembling_meca.m: -------------------------------------------------------------------------------- 1 | % Copyright (C) 2003-2011 2 | % Lounes ILLOUL (illoul_lounes@yahoo.fr) 3 | % Philippe LORONG (philippe.lorong@ensam.eu) 4 | % Arts et Metiers ParisTech, Paris, France 5 | 6 | function [B,C,V]= m_assembling_meca(GS,E_NU) 7 | 8 | n=size(GS.Vol_C,2); 9 | dim=size(GS.Grad,1); 10 | nb_var=dim; 11 | 12 | B=cal_B_Mat_meca(cal_B_Mat(GS,nb_var),dim); 13 | C=cal_Behav_Mat_meca(E_NU,n,dim); 14 | V=cal_Mat_Vec(GS.Vol_C',ones(size(B,1)/n,1)); 15 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/m_assembling_thermal.m: -------------------------------------------------------------------------------- 1 | % Copyright (C) 2003-2011 2 | % Lounes ILLOUL (illoul_lounes@yahoo.fr) 3 | % Philippe LORONG (philippe.lorong@ensam.eu) 4 | % Arts et Metiers ParisTech, Paris, France 5 | 6 | function [B,C,V]= m_assembling_thermal(GS,K) 7 | 8 | n=size(GS.Vol_C,2); 9 | dim=size(GS.Grad,1); 10 | nb_var=1; 11 | 12 | B=cal_B_Mat_therm(cal_B_Mat(GS,nb_var),dim); 13 | C=cal_Behav_Mat_therm(K,n,dim); 14 | V=cal_Mat_Vec(GS.Vol_C',ones(size(B,1)/n,1)); 15 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/m_cnem2d_mesh.m: -------------------------------------------------------------------------------- 1 | % This file is part of CNEMLIB. 2 | % 3 | % Copyright (C) 2003-2011 4 | % Lounes ILLOUL (illoul_lounes@yahoo.fr) 5 | % Philippe LORONG (philippe.lorong@ensam.eu) 6 | % Arts et Metiers ParisTech, Paris, France 7 | % 8 | % CNEMLIB is free software: you can redistribute it and/or modify 9 | % it under the terms of the GNU Lesser General Public License as published by 10 | % the Free Software Foundation, either version 3 of the License, or 11 | % (at your option) any later version. 12 | % 13 | % CNEMLIB is distributed in the hope that it will be useful, 14 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | % GNU Lesser General Public License for more details. 17 | % 18 | % You should have received a copy of the GNU Lesser General Public License 19 | % along with Foobar. If not, see . 20 | % 21 | % Please report bugs to illoul_lounes@yahoo.fr 22 | 23 | function [XY_Noeud_New,IN_Front_New,IN_Tri,IN_New_Old,IN_Old_New]=... 24 | m_cnem2d_mesh(XY_Noeud,Nb_Noeud_Front,IN_Front) 25 | 26 | a=sparse(1,1);s=whos('a'); 27 | if s.bytes==20 %32bit 28 | Nb_Noeud_Front=uint32(Nb_Noeud_Front); 29 | IN_Front=uint32(IN_Front-1); 30 | else %64bit 31 | Nb_Noeud_Front=uint64(Nb_Noeud_Front); 32 | IN_Front=uint64(IN_Front-1); 33 | end 34 | 35 | [IN_New_Old,IN_Old_New,IN_Tri]=cnem2d(2,XY_Noeud',Nb_Noeud_Front',IN_Front'); 36 | 37 | IN_New_Old=double(IN_New_Old)'; 38 | IN_Old_New=double(IN_Old_New)'; 39 | IN_Tri=double(IN_Tri)'+1; 40 | IN_Front=double(IN_Front)+1; 41 | 42 | XY_Noeud_New=XY_Noeud(IN_Old_New,:); 43 | IN_Front_New=IN_New_Old(IN_Front); 44 | 45 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/m_cnem3d_mesh.m: -------------------------------------------------------------------------------- 1 | % This file is part of CNEMLIB. 2 | % 3 | % Copyright (C) 2003-2011 4 | % Lounes ILLOUL (illoul_lounes@yahoo.fr) 5 | % Philippe LORONG (philippe.lorong@ensam.eu) 6 | % Arts et Metiers ParisTech, Paris, France 7 | % 8 | % CNEMLIB is free software: you can redistribute it and/or modify 9 | % it under the terms of the GNU Lesser General Public License as published by 10 | % the Free Software Foundation, either version 3 of the License, or 11 | % (at your option) any later version. 12 | % 13 | % CNEMLIB is distributed in the hope that it will be useful, 14 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | % GNU Lesser General Public License for more details. 17 | % 18 | % You should have received a copy of the GNU Lesser General Public License 19 | % along with Foobar. If not, see . 20 | % 21 | % Please report bugs to illoul_lounes@yahoo.fr 22 | 23 | function [XYZ_Noeud_New,IN_Tri_Ini_New,IN_Tri,IN_Tet,IN_New_Old,IN_Old_New]=... 24 | m_cnem3d_mesh(XYZ_Noeud,IN_Tri_Ini) 25 | 26 | Type_Call_Tet=1; 27 | 28 | a=sparse(1,1);s=whos('a'); 29 | if s.bytes==20 %32bit 30 | IN_Tri_Ini=uint32(IN_Tri_Ini-1); 31 | else %64bit 32 | IN_Tri_Ini=uint64(IN_Tri_Ini-1); 33 | end 34 | 35 | [IN_New_Old,IN_Old_New,XYZ_New_Noeud,IN_Tri,IN_Tet]=... 36 | cnem3d(2,XYZ_Noeud',IN_Tri_Ini',Type_Call_Tet); 37 | 38 | IN_New_Old=double(IN_New_Old)'; 39 | IN_Old_New=double(IN_Old_New)'; 40 | IN_Tri=double(IN_Tri)'+1; 41 | IN_Tet=double(IN_Tet)'+1; 42 | IN_Tri_Ini=double(IN_Tri_Ini)+1; 43 | 44 | XYZ_Noeud_New=[XYZ_Noeud(IN_Old_New,:);XYZ_New_Noeud']; 45 | IN_Tri_Ini_New=IN_New_Old(IN_Tri_Ini); 46 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/plot_bord_and_node.m: -------------------------------------------------------------------------------- 1 | function plot_bondary(XY_Node,Nb_Node_Front,Ind_Node_Front) 2 | 3 | j=1; 4 | for i=1:size(Nb_Node_Front,1) 5 | XY_Node_Front_i=XY_Node(Ind_Node_Front([j:(j+Nb_Node_Front(i)-1)]),:); 6 | for k=1:Nb_Node_Front(i) 7 | text(XY_Node_Front_i(k,1),XY_Node_Front_i(k,2),num2str(k)) 8 | end 9 | plot(XY_Node_Front_i(:,1),XY_Node_Front_i(:,2),'color','red','LineWidth',2); 10 | j=j+Nb_Node_Front(i); 11 | end 12 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/plot_boundary.m: -------------------------------------------------------------------------------- 1 | function plot_boundary(XY_Node,Nb_Node_Front,Ind_Node_Front) 2 | 3 | j=1; 4 | for i=1:size(Nb_Node_Front,1) 5 | XY_Node_Front_i=XY_Node(Ind_Node_Front([j:(j+Nb_Node_Front(i)-1)]),:); 6 | for k=1:Nb_Node_Front(i) 7 | text(XY_Node_Front_i(k,1),XY_Node_Front_i(k,2),num2str(k)) 8 | end 9 | plot(XY_Node_Front_i(:,1),XY_Node_Front_i(:,2),'color','red','LineWidth',2); 10 | j=j+Nb_Node_Front(i); 11 | end 12 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/plot_cel_vc.m: -------------------------------------------------------------------------------- 1 | function plot_cel_vc(Cel,Var) 2 | 3 | Ind_Noeud_Cel=Cel.Ind_Noeud_Cel; 4 | Nb_S_Cel=Cel.Nb_S_Cel; 5 | S_Cel=Cel.S_Cel; 6 | 7 | j=1; 8 | for i=1:size(Ind_Noeud_Cel,1) 9 | J=j+Nb_S_Cel(i); 10 | patch(S_Cel(j:J-1,1),S_Cel(j:J-1,2),Var(Ind_Noeud_Cel(i))); 11 | j=J; 12 | end 13 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/sparse_block.m: -------------------------------------------------------------------------------- 1 | % Copyright (C) 2003-2011 2 | % Lounes ILLOUL (illoul_lounes@yahoo.fr) 3 | % Philippe LORONG (philippe.lorong@ensam.eu) 4 | % Arts et Metiers ParisTech, Paris, France 5 | 6 | function SP=sparse_block(vec_mat,m,nb_mat) 7 | 8 | nb_mat_bis=size(vec_mat,1)/m; 9 | n=size(vec_mat,2); 10 | 11 | const=0; 12 | if nb_mat_bis==1 13 | const=1; 14 | end 15 | 16 | nb_elem=m*n; 17 | nb_elem_glob=nb_elem*nb_mat; 18 | 19 | I_SP=zeros(1,nb_elem_glob); 20 | J_SP=zeros(1,nb_elem_glob); 21 | 22 | if const==1 23 | V_SP=zeros(1,nb_elem_glob); 24 | vec_mat=reshape(vec_mat',nb_elem,1)'; 25 | for i=1:nb_mat 26 | V_SP(nb_elem*(i-1)+1:nb_elem*i)=vec_mat; 27 | end 28 | else 29 | V_SP=reshape(vec_mat',nb_elem_glob,1)'; 30 | end 31 | 32 | I=ones(1,n); 33 | for i=1:nb_mat 34 | J=n*(i-1)+1:n*i; 35 | for j=1:m 36 | k=m*(i-1)+j; 37 | l=n*(k-1)+1:n*k; 38 | I_SP(l)=k*I; 39 | J_SP(l)=J; 40 | end 41 | end 42 | 43 | SP=sparse(I_SP,J_SP,V_SP,nb_mat*m,nb_mat*n); 44 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/test_script.m: -------------------------------------------------------------------------------- 1 | load('/home/paula/Work/Code/Networks/brain-waves/data/513COG.mat') 2 | shpalpha = 30; % alpha radius; may need tweaking depending on geometry (of cortex?) 3 | shp = alphaShape(COG, shpalpha); 4 | bdy = shp.boundaryFacets; 5 | Type_FF = 0;% 0 -> Sibson, 1 -> Laplace, 2 -> Linear fem 6 | Sup_NN_GS = 0;% 7 | 8 | % file 'tet' needs to be in your system's PATH variable, does not work to 9 | % set it in matlab 10 | % or make it executable 11 | 12 | %setenv('PATH', ['/home/paula/Work/Code/Networks/neural-flows/external/cnem_03-10-17/matlab/bin:' getenv('PATH')]); 13 | %export PATH=/home/paula/Work/Code/Networks/neural-flows/external/cnem_03-10-17/matlab/bin:$PATH 14 | [GS,XYZ,IN_Tri_Ini,IN_Tri,IN_Tet,INV_NN,PNV_NN,IN_New_Old,IN_Old_New] = m_cnem3d_scni(COG, bdy, Type_FF, Sup_NN_GS); 15 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/bin/tet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/external/cnem_03-10-17/matlab/bin/tet -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/libbuild/make_cnem2d.m: -------------------------------------------------------------------------------- 1 | clc; 2 | delete *.o* 3 | 4 | tbb_dir='F:\A\DATA\1\dev\lib\tbb41_20130314oss'; 5 | 6 | %linux 7 | %TBB_INC_DIR =[tbb_dir '/include']; 8 | %TBB_LIB_DIR =[tbb_dir '/lib/intel64/cc4.1.0_libc2.4_kernel2.6.16.21']; 9 | 10 | %mac 11 | %TBB_INC_DIR =[tbb_dir '/include']; 12 | %TBB_LIB_DIR =[tbb_dir '/lib']; 13 | 14 | %win 15 | TBB_INC_DIR =[tbb_dir '/include']; 16 | TBB_LIB_DIR =[tbb_dir '/lib/intel64/vc9']; 17 | 18 | tbb_lib={'tbb'}; 19 | 20 | func_name='../bin/cnem2d'; 21 | src={{'../../src/CNEM2D/'} {'C_Pnt2d' 'C_Vec2d' 'C_Cellule' 'C_Meshless_2d' 'scni_cnem2d' 'interpol_cnem2d' 'mesh_cnem2d' 'gauss_cnem2d' 'cnem2d_mex'} {' -largeArrayDims -I../../src/UTILE/'} 22 | {'../../src/UTILE/'} {'pnt_gauss_2d'} {' -largeArrayDims'}}; 23 | 24 | lib={TBB_INC_DIR TBB_LIB_DIR tbb_lib}; 25 | lopt=' -largeArrayDims'; 26 | make_mex_func(func_name,src,lib,lopt) 27 | 28 | delete *.o* -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/libbuild/make_cnem3d.m: -------------------------------------------------------------------------------- 1 | % NOTE: PSL: you need to call this function from inside the directory is 2 | % in. 3 | 4 | clc; 5 | delete *.o* 6 | 7 | tbb_dir='/home/paula/Downloads/Software/tbb2018_20170919oss_lin/tbb2018_20170919oss'; 8 | %'../../extern/tbb42_20140122oss'; 9 | 10 | %linux 11 | TBB_INC_DIR =[tbb_dir '/include']; 12 | TBB_LIB_DIR =[tbb_dir '/lib/intel64/gcc4.7'];%'/lib/intel64/cc4.1.0_libc2.4_kernel2.6.16.21']; 13 | 14 | %tbb_dir='F:\A\DATA\1\dev\lib\tbb41_20130314oss'; 15 | 16 | %linux 17 | %TBB_INC_DIR =[tbb_dir '/include']; 18 | %TBB_LIB_DIR =[tbb_dir '/lib/intel64/cc4.1.0_libc2.4_kernel2.6.16.21']; 19 | 20 | %mac 21 | %TBB_INC_DIR =[tbb_dir '/include']; 22 | %TBB_LIB_DIR =[tbb_dir '/lib']; 23 | 24 | %win 25 | %TBB_INC_DIR =[tbb_dir '/include']; 26 | %TBB_LIB_DIR =[tbb_dir '/lib/intel64/vc9']; 27 | 28 | tbb_lib={'tbb'}; 29 | 30 | func_name='../bin/cnem3d'; 31 | src={{'../../src/CNEM3D/'} {'cnem3d_mex' 'scni_cnem3d' 'interpol_cnem3d' 'mesh_cnem3d' 'C_Pnt3d' 'C_Vec3d' 'C_Sommet' 'C_Cellule'... 32 | 'C_Diag_Vor' 'C_Meshless_3d_DVC' 'C_Meshless_3d_C_Meshless_3d'... 33 | 'C_Meshless_3d_PntGau' 'C_Meshless_3d_Tri' 'Const_Top_Front' 'Group_Tet'... 34 | 'C_Meshless_3d_ff' 'C_Meshless_3d_IntNoeEsc' 'C_Meshless_3d_Util'... 35 | 'InterpolParal' 'GradStabParal' 'out_elem_celqt'} {'-DTETLIBRARY -I../../src/TETGEN/'} 36 | {'../../src/TETGEN/'} {'tetgen'} {'-DTETLIBRARY -DWall -DDSELF_CHECK'} 37 | {'../../src/TETGEN/'} {'predicates'} {'-g'}}; 38 | 39 | 40 | lib={TBB_INC_DIR TBB_LIB_DIR tbb_lib}; 41 | lopt=''; 42 | make_mex_func(func_name,src,lib,lopt) 43 | 44 | delete *.o* -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/libbuild/make_mex_func.m: -------------------------------------------------------------------------------- 1 | function make_mex_func(func_name,src,lib,lopt) 2 | 3 | %---------------------------------------------------------- 4 | 5 | libI=''; 6 | libL=''; 7 | libs=''; 8 | for i=1:size(lib,1) 9 | libI=[libI ' -I' char(lib{i,1})]; 10 | libL=[libL ' -L' char(lib{i,2})]; 11 | for j=1:size(lib{i,3},2) 12 | libs=[libs ' -l' char(lib{i,3}(j))]; 13 | end 14 | end 15 | 16 | %---------------------------------------------------------- 17 | 18 | for i=1:size(src,1) 19 | for j=1:size(src{i,2},2) 20 | src_ij=strcat(char(src{i,1}),char(src{i,2}(j)),'.cpp'); 21 | cmd=['mex ' char(src{i,3}) ' ' libI ' -c ' src_ij]; 22 | eval(cmd); 23 | end 24 | end 25 | 26 | arch=computer('arch'); 27 | objext='.o'; 28 | if strcmp(arch(1:3),'win') 29 | objext='.obj'; 30 | end 31 | 32 | cmd=['mex ' lopt ' -output ' func_name ' ' libL ' ' libs ' ']; 33 | for i=1:size(src,1) 34 | for j=1:size(src{i,2},2) 35 | obj_ij=strcat(char(src{i,2}(j)),objext); 36 | cmd=[cmd ' ' obj_ij]; 37 | end 38 | end 39 | cmd 40 | eval(cmd) -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/libbuild/make_tet: -------------------------------------------------------------------------------- 1 | CPP=g++ 2 | CFLAGS=-O2 -fpic -DTETLIBRARY -m32 3 | LDFLAGS= -m32 4 | 5 | CXX=g++ 6 | CXXFLAGS=-O2 -fpic -DTETLIBRARY -m32 7 | PREDCXXFLAGS=-O0 -fpic -m32 8 | SWITCHES=-Wall -DSELF_CHECK 9 | 10 | EXE=tet 11 | DIRSRCC=../../src/CNEM3D 12 | DIRSRCT=../../src/TETGEN 13 | DIROUT=../bin 14 | 15 | $(EXE):$(DIRSRCT)/predicates.cpp $(DIRSRCT)/tetgen.cpp $(DIRSRCC)/main_tetgen_exe.cpp 16 | $(CPP) -I$(DIRSRCT) $(CFLAGS) -c $(DIRSRCC)/main_tetgen_exe.cpp 17 | $(CXX) $(PREDCXXFLAGS) -c $(DIRSRCT)/predicates.cpp 18 | $(CXX) $(CXXFLAGS) $(SWITCHES) -c $(DIRSRCT)/tetgen.cpp 19 | $(CPP) -o $(DIROUT)/$@ $(LDFLAGS) predicates.o tetgen.o main_tetgen_exe.o 20 | 21 | .PHONY: clean mrproper 22 | 23 | clean: 24 | rm -rf *.o 25 | 26 | rmproper: clean 27 | rm -rf $(DIROUT)/$(EXE) 28 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/libbuild/make_tet.bat: -------------------------------------------------------------------------------- 1 | call "%VS90COMNTOOLS%vsvars32.bat" 2 | cl /c ../../src/CNEM3D/main_tetgen_exe.cpp /DTETLIBRARY /I../../src/TETGEN/ /EHsc 3 | cl /c ../../src/TETGEN/predicates.cpp /Od /EHsc 4 | cl /c ../../src/TETGEN/tetgen.cpp -DTETLIBRARY /I../../src/TETGEN/ /EHsc 5 | cl /Fe../bin/tet predicates.obj tetgen.obj main_tetgen_exe.obj /EHsc 6 | 7 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/matlab/tuto2d/f_bord_func.m: -------------------------------------------------------------------------------- 1 | function f=f_bord_func(xy) 2 | 3 | eps=1.e-9; 4 | 5 | f=[0. 6 | 0.]; 7 | 8 | if abs(xy(2)-1.) r_int 46 | id_tet_util=[id_tet_util;i]; 47 | end 48 | 49 | end 50 | 51 | figure; 52 | hold on 53 | tri_out_handle=trimesh(IN_Tri,XYZ_Noeud(:,1),XYZ_Noeud(:,2),XYZ_Noeud(:,3),'edgecolor','black'); 54 | tet_out_handle=tetramesh(IN_Tet(id_tet_util,:),XYZ_Noeud,'edgecolor','black'); 55 | alpha(tri_out_handle,0.5); 56 | alpha(tet_out_handle,0.5); 57 | plot3(XYZ_Noeud(:,1),XYZ_Noeud(:,2),XYZ_Noeud(:,3),'.','color','red'); 58 | axis vis3d 59 | axis equal 60 | hold off 61 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/python/bin/CNEM3D.cpython-37m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/external/cnem_03-10-17/python/bin/CNEM3D.cpython-37m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /external/cnem_03-10-17/python/bin/bbox_005: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/external/cnem_03-10-17/python/bin/bbox_005 -------------------------------------------------------------------------------- /external/cnem_03-10-17/python/bin/bbox_01: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/external/cnem_03-10-17/python/bin/bbox_01 -------------------------------------------------------------------------------- /external/cnem_03-10-17/python/bin/bbox_02: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/external/cnem_03-10-17/python/bin/bbox_02 -------------------------------------------------------------------------------- /external/cnem_03-10-17/python/bin/bbox_03: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/external/cnem_03-10-17/python/bin/bbox_03 -------------------------------------------------------------------------------- /external/cnem_03-10-17/python/bin/check_gs.py: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of CNEMLIB. 3 | ## 4 | ## Copyright (C) 2003-2011 5 | ## Lounes ILLOUL (illoul_lounes@yahoo.fr) 6 | ## Philippe LORONG (philippe.lorong@ensam.eu) 7 | ## Arts et Metiers ParisTech, Paris, France 8 | ## 9 | ## CNEMLIB is free software: you can redistribute it and/or modify 10 | ## it under the terms of the GNU Lesser General Public License as published by 11 | ## the Free Software Foundation, either version 3 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## CNEMLIB is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU Lesser General Public License for more details. 18 | ## 19 | ## You should have received a copy of the GNU Lesser General Public License 20 | ## along with Foobar. If not, see . 21 | ## 22 | ## Please report bugs to illoul_lounes@yahoo.fr 23 | 24 | import numpy as np 25 | from scipy.sparse import coo_matrix 26 | 27 | def check(GS,Coord): 28 | row=np.zeros(len(GS[2])) 29 | k=0 30 | for i in range(len(GS[1])): 31 | for j in range(GS[1][i]): 32 | row[k]=i 33 | k=k+1 34 | 35 | dim=len(GS[3])/len(GS[2]) 36 | 37 | for i in range(dim): 38 | B_i=coo_matrix((GS[3][i::dim],(row,GS[2]))) 39 | r=B_i*Coord 40 | s='' 41 | for i in range(dim): 42 | s=s+'('+str(np.min(r[:,i],0))+' - '+str(np.max(r[:,i],0))+') ' 43 | print s 44 | 45 | return 46 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/python/bin/tet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/external/cnem_03-10-17/python/bin/tet -------------------------------------------------------------------------------- /external/cnem_03-10-17/python/libbuild/main_tetgen_exe.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/external/cnem_03-10-17/python/libbuild/main_tetgen_exe.o -------------------------------------------------------------------------------- /external/cnem_03-10-17/python/libbuild/make_tet: -------------------------------------------------------------------------------- 1 | CPP=g++ 2 | CFLAGS=-O2 -fpic -DTETLIBRARY -m32 3 | LDFLAGS=-m32 4 | 5 | CXX=g++ 6 | CXXFLAGS=-O2 -fpic -DTETLIBRARY -m32 7 | PREDCXXFLAGS=-O0 -fpic -m32 8 | SWITCHES=-Wall -DSELF_CHECK 9 | 10 | EXE=tet 11 | DIRSRCC=../../src/CNEM3D 12 | DIRSRCT=../../src/TETGEN 13 | DIROUT=../bin 14 | 15 | $(EXE):$(DIRSRCT)/predicates.cpp $(DIRSRCT)/tetgen.cpp $(DIRSRCC)/main_tetgen_exe.cpp 16 | $(CPP) -I$(DIRSRCT) $(CFLAGS) -c $(DIRSRCC)/main_tetgen_exe.cpp 17 | $(CXX) $(PREDCXXFLAGS) -c $(DIRSRCT)/predicates.cpp 18 | $(CXX) $(CXXFLAGS) $(SWITCHES) -c $(DIRSRCT)/tetgen.cpp 19 | $(CPP) -o $(DIROUT)/$@ $(LDFLAGS) predicates.o tetgen.o main_tetgen_exe.o 20 | 21 | .PHONY: clean mrproper 22 | 23 | clean: 24 | rm -rf *.o 25 | 26 | rmproper: clean 27 | rm -rf $(DIROUT)/$(EXE) 28 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/python/libbuild/make_tet.bat: -------------------------------------------------------------------------------- 1 | call "%VS100COMNTOOLS%vsvars32.bat" 2 | cl /c ../../src/CNEM3D/main_tetgen_exe.cpp /DTETLIBRARY /I../../src/TETGEN/ /EHsc 3 | cl /c ../../src/TETGEN/predicates.cpp /Od /EHsc 4 | cl /c ../../src/TETGEN/tetgen.cpp -DTETLIBRARY /I../../src/TETGEN/ /EHsc 5 | cl /Fe../bin/tet predicates.obj tetgen.obj main_tetgen_exe.obj /EHsc 6 | 7 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/python/libbuild/predicates.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/external/cnem_03-10-17/python/libbuild/predicates.o -------------------------------------------------------------------------------- /external/cnem_03-10-17/python/libbuild/temp/home/paula/Work/Code/Matlab/cnem_03-10-17/src/TETGEN/predicates.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/external/cnem_03-10-17/python/libbuild/temp/home/paula/Work/Code/Matlab/cnem_03-10-17/src/TETGEN/predicates.o -------------------------------------------------------------------------------- /external/cnem_03-10-17/python/libbuild/tetgen.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/external/cnem_03-10-17/python/libbuild/tetgen.o -------------------------------------------------------------------------------- /external/cnem_03-10-17/python/tuto/data2d_small/ind_nf.dat: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | 2 4 | 3 5 | 4 6 | 5 7 | 6 8 | 7 9 | 8 10 | 9 11 | 10 12 | 11 13 | 12 14 | 13 15 | 14 16 | 15 17 | 16 18 | 17 19 | 18 20 | 19 21 | 20 22 | 21 23 | 22 24 | 23 25 | 24 26 | 25 27 | 26 28 | 27 29 | 28 30 | 29 31 | 30 32 | 31 33 | 32 34 | 33 35 | 34 36 | 35 37 | 36 38 | 37 39 | 38 40 | 39 41 | 40 42 | 41 43 | 42 44 | 43 45 | 44 46 | 45 47 | 46 48 | 47 49 | 48 50 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/python/tuto/data2d_small/nb_nf.dat: -------------------------------------------------------------------------------- 1 | 40 2 | 9 3 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/python/tuto/load_node_front.py: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003-2011 3 | ## Lounes ILLOUL (illoul_lounes@yahoo.fr) 4 | ## Philippe LORONG (philippe.lorong@ensam.eu) 5 | ## Arts et Metiers ParisTech, Paris, France 6 | ## 7 | ## $Revision$ - $Date$ 8 | 9 | def load2d(data_path): 10 | 11 | File = open(data_path+'xy.dat','r') 12 | XY_Noeud=list() 13 | for e in File: 14 | XY_Noeud.append(float(e)) 15 | File.close() 16 | 17 | Nb_Noeud_Front=list() 18 | File = open(data_path+'nb_nf.dat','r') 19 | for e in File: 20 | Nb_Noeud_Front.append(int(e)) 21 | File.close() 22 | 23 | Ind_Noeud_Front=list() 24 | File = open(data_path+'ind_nf.dat','r') 25 | for e in File: 26 | Ind_Noeud_Front.append(int(e)) 27 | File.close() 28 | 29 | return XY_Noeud,Nb_Noeud_Front,Ind_Noeud_Front 30 | 31 | def load3d(data_path): 32 | 33 | File = open(data_path+'xyz.dat','r') 34 | XYZ_Noeud=list() 35 | for e in File: 36 | XYZ_Noeud.append(float(e)) 37 | File.close() 38 | 39 | Tri_Front=list() 40 | File = open(data_path+'tri.dat','r') 41 | for e in File: 42 | Tri_Front.append(int(e)) 43 | File.close() 44 | 45 | return XYZ_Noeud,Tri_Front 46 | 47 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/src/CNEM2D/C_Cellule.h: -------------------------------------------------------------------------------- 1 | /* This file is part of CNEMLIB. 2 | 3 | Copyright (C) 2003-2011 4 | Lounes ILLOUL (illoul_lounes@yahoo.fr) 5 | Philippe LORONG (philippe.lorong@ensam.eu) 6 | Arts et Metiers ParisTech, Paris, France 7 | 8 | CNEMLIB is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | CNEMLIB is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with Foobar. If not, see . 20 | 21 | Please report bugs to illoul_lounes@yahoo.fr */ 22 | 23 | #ifndef C_Cellule_H 24 | #define C_Cellule_H 25 | 26 | #include "C_Vec2d.h" 27 | 28 | struct S_Sommet 29 | { 30 | bool Valide; 31 | bool Sommet_Infini; 32 | 33 | long Ind_MExt; 34 | long Ind_SExt; 35 | 36 | C_Pnt2d Coord_Sommet; 37 | double Rayon_Cercle; 38 | 39 | long Ind_Noeud[3]; 40 | long Ind_Sommet[3]; 41 | }; 42 | 43 | struct S_Arete 44 | { 45 | long Ind_Noeud; 46 | long Ind_Sommet[2]; 47 | }; 48 | 49 | class C_Cellule 50 | { 51 | public: 52 | 53 | bool Fermee; 54 | list* P_List_Arete; 55 | 56 | C_Cellule(); 57 | void Build_Topologie(); 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/src/CNEM2D/C_Pnt2d.h: -------------------------------------------------------------------------------- 1 | /* This file is part of CNEMLIB. 2 | 3 | Copyright (C) 2003-2011 4 | Lounes ILLOUL (illoul_lounes@yahoo.fr) 5 | Philippe LORONG (philippe.lorong@ensam.eu) 6 | Arts et Metiers ParisTech, Paris, France 7 | 8 | CNEMLIB is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | CNEMLIB is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with Foobar. If not, see . 20 | 21 | Please report bugs to illoul_lounes@yahoo.fr */ 22 | 23 | #ifndef C_Pnt2d_H 24 | #define C_Pnt2d_H 25 | 26 | #include "Global_Header.h" 27 | 28 | class C_Pnt2d 29 | { 30 | 31 | public: 32 | 33 | // Methods PUBLIC 34 | // 35 | C_Pnt2d(); 36 | C_Pnt2d(const double Xp,const double Yp); 37 | void SetCoord(const double Xp,const double Yp) ; 38 | void SetX(const double X) ; 39 | void SetY(const double Y) ; 40 | double X() const; 41 | double Y() const; 42 | double Distance(const C_Pnt2d& Other) const; 43 | double SquareDistance(const C_Pnt2d& Other) const; 44 | 45 | private: 46 | 47 | double myX; 48 | double myY; 49 | 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/src/CNEM2D/Global_Header.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/external/cnem_03-10-17/src/CNEM2D/Global_Header.h -------------------------------------------------------------------------------- /external/cnem_03-10-17/src/CNEM2D/gauss_cnem2d.h: -------------------------------------------------------------------------------- 1 | /* This file is part of CNEMLIB. 2 | 3 | Copyright (C) 2003-2011 4 | Lounes ILLOUL (illoul_lounes@yahoo.fr) 5 | Philippe LORONG (philippe.lorong@ensam.eu) 6 | Arts et Metiers ParisTech, Paris, France 7 | 8 | CNEMLIB is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | CNEMLIB is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with Foobar. If not, see . 20 | 21 | Please report bugs to illoul_lounes@yahoo.fr */ 22 | 23 | #pragma once 24 | 25 | #include 26 | using namespace std; 27 | 28 | #include "mat_map.h" 29 | 30 | int gauss_cnem2d 31 | (//IN 32 | size_t Nb_Noeud, 33 | double* P_XY_Noeud, 34 | size_t Nb_Front, 35 | size_t* P_Nb_Noeud_Front, 36 | size_t* P_Ind_Noeud_Front, 37 | long Ind_LPG, 38 | long Axi, 39 | bool Row_Major, 40 | double Zero_Sparse, 41 | double** Tab_Vec_Coef, 42 | //OUT 43 | vector* P_Vec_Ind_Noeud_New_Old, 44 | vector* P_Vec_Ind_Noeud_Old_New, 45 | vector* P_Vec_Tri, 46 | Mat_Map** Tab_Map_Mat 47 | ); 48 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/src/CNEM2D/interpol_cnem2d.h: -------------------------------------------------------------------------------- 1 | /* This file is part of CNEMLIB. 2 | 3 | Copyright (C) 2003-2011 4 | Lounes ILLOUL (illoul_lounes@yahoo.fr) 5 | Philippe LORONG (philippe.lorong@ensam.eu) 6 | Arts et Metiers ParisTech, Paris, France 7 | 8 | CNEMLIB is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | CNEMLIB is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with Foobar. If not, see . 20 | 21 | Please report bugs to illoul_lounes@yahoo.fr */ 22 | 23 | #pragma once 24 | 25 | #include 26 | using namespace std; 27 | 28 | int interpol_cnem2d 29 | (//IN 30 | size_t Nb_Noeud, 31 | double* P_XY_Noeud, 32 | size_t Nb_Front, 33 | size_t* P_Nb_Noeud_Front, 34 | size_t* P_Ind_Noeud_Front, 35 | size_t Nb_PntInt, 36 | double* P_XY_PntInt, 37 | //OUT 38 | vector* P_Vec_Ind_Noeud_New_Old, 39 | vector* P_Vec_Ind_Noeud_Old_New, 40 | vector* P_Vec_Nb_Contrib, 41 | vector* P_Vec_INV, 42 | vector* P_Vec_Phi, 43 | vector* P_Vec_Gard); 44 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/src/CNEM2D/mesh_cnem2d.h: -------------------------------------------------------------------------------- 1 | /* This file is part of CNEMLIB. 2 | 3 | Copyright (C) 2003-2011 4 | Lounes ILLOUL (illoul_lounes@yahoo.fr) 5 | Philippe LORONG (philippe.lorong@ensam.eu) 6 | Arts et Metiers ParisTech, Paris, France 7 | 8 | CNEMLIB is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | CNEMLIB is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with Foobar. If not, see . 20 | 21 | Please report bugs to illoul_lounes@yahoo.fr */ 22 | 23 | #pragma once 24 | 25 | #include 26 | using namespace std; 27 | 28 | int mesh_cnem2d 29 | (//IN 30 | size_t Nb_Noeud, 31 | double* P_XY_Noeud, 32 | size_t Nb_Front, 33 | size_t* P_Nb_Noeud_Front, 34 | size_t* P_Ind_Noeud_Front, 35 | //OUT 36 | vector* P_Vec_Ind_Noeud_New_Old, 37 | vector* P_Vec_Ind_Noeud_Old_New, 38 | vector* P_Vec_Tri); 39 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/src/CNEM2D/scni_cnem2d.h: -------------------------------------------------------------------------------- 1 | /* This file is part of CNEMLIB. 2 | 3 | Copyright (C) 2003-2011 4 | Lounes ILLOUL (illoul_lounes@yahoo.fr) 5 | Philippe LORONG (philippe.lorong@ensam.eu) 6 | Arts et Metiers ParisTech, Paris, France 7 | 8 | CNEMLIB is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | CNEMLIB is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with Foobar. If not, see . 20 | 21 | Please report bugs to illoul_lounes@yahoo.fr */ 22 | 23 | #pragma once 24 | 25 | #include 26 | using namespace std; 27 | 28 | int scni_cnem2d 29 | (//IN 30 | size_t Nb_Noeud, 31 | double* P_XY_Noeud, 32 | size_t Nb_Front, 33 | size_t* P_Nb_Noeud_Front, 34 | size_t* P_Ind_Noeud_Front, 35 | bool out_cel_vc, 36 | bool axi, 37 | //OUT 38 | vector* P_Vec_Ind_Noeud_New_Old, 39 | vector* P_Vec_Ind_Noeud_Old_New, 40 | vector* P_Vec_Vol_Cel, 41 | vector* P_Vec_XY_CdM, 42 | vector* P_Vec_Nb_Contrib, 43 | vector* P_Vec_INV, 44 | vector* P_Vec_Grad, 45 | vector* P_Vec_Tri, 46 | vector* P_Ind_Noeud_Cel, 47 | vector* P_Nb_S_Cel, 48 | vector* P_S_Cel, 49 | vector* P_Vec_Nb_Contrib_Int, 50 | vector* P_Vec_INV_Int, 51 | vector* P_Vec_Phi_Int); -------------------------------------------------------------------------------- /external/cnem_03-10-17/src/CNEM3D/C_Cellule.h: -------------------------------------------------------------------------------- 1 | /* This file is part of CNEMLIB. 2 | 3 | Copyright (C) 2003-2011 4 | Lounes ILLOUL (illoul_lounes@yahoo.fr) 5 | Philippe LORONG (philippe.lorong@ensam.eu) 6 | Arts et Metiers ParisTech, Paris, France 7 | 8 | CNEMLIB is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | CNEMLIB is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with Foobar. If not, see . 20 | 21 | Please report bugs to illoul_lounes@yahoo.fr */ 22 | 23 | #pragma once 24 | 25 | #include"C_Sommet.h" 26 | 27 | 28 | struct C_Sommet_1 29 | { 30 | long Ind_Noeud[3]; 31 | 32 | long Ind_Sommet_Externe; 33 | 34 | C_Sommet_1* P_Sommet[3]; 35 | 36 | double Sommet[3]; 37 | double Rayon_Sphere; 38 | }; 39 | 40 | struct S_Arete_V_1 41 | { 42 | long Ind_Noeud; 43 | C_Sommet_1* P_Sommet[2]; 44 | }; 45 | 46 | struct S_Face_V_1 47 | { 48 | long Ind_Noeud; 49 | vector* P_List_P_Arete; 50 | }; 51 | 52 | class C_Cellule 53 | { 54 | public: 55 | 56 | vector List_P_Sommet; 57 | vector List_P_Face; 58 | 59 | void Build_Topologie(); 60 | ~C_Cellule(); 61 | }; 62 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/src/CNEM3D/C_Pnt3d.h: -------------------------------------------------------------------------------- 1 | /* This file is part of CNEMLIB. 2 | 3 | Copyright (C) 2003-2011 4 | Lounes ILLOUL (illoul_lounes@yahoo.fr) 5 | Philippe LORONG (philippe.lorong@ensam.eu) 6 | Arts et Metiers ParisTech, Paris, France 7 | 8 | CNEMLIB is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | CNEMLIB is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with Foobar. If not, see . 20 | 21 | Please report bugs to illoul_lounes@yahoo.fr */ 22 | 23 | #pragma once 24 | 25 | #include "Global_Header.h" 26 | 27 | class C_Pnt3d { 28 | 29 | public: 30 | 31 | // Methods PUBLIC 32 | // 33 | C_Pnt3d(); 34 | C_Pnt3d(const double Xp,const double Yp,const double Zp); 35 | void SetCoord(const double Xp,const double Yp,const double Zp) ; 36 | void SetX(const double X) ; 37 | void SetY(const double Y) ; 38 | void SetZ(const double Z) ; 39 | 40 | double X() const; 41 | double Y() const; 42 | double Z() const; 43 | double Distance(const C_Pnt3d& Other) const; 44 | double SquareDistance(const C_Pnt3d& Other) const; 45 | 46 | private: 47 | 48 | double myX; 49 | double myY; 50 | double myZ; 51 | }; 52 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/src/CNEM3D/Const_Top_Front.h: -------------------------------------------------------------------------------- 1 | /* This file is part of CNEMLIB. 2 | 3 | Copyright (C) 2003-2011 4 | Lounes ILLOUL (illoul_lounes@yahoo.fr) 5 | Philippe LORONG (philippe.lorong@ensam.eu) 6 | Arts et Metiers ParisTech, Paris, France 7 | 8 | CNEMLIB is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | CNEMLIB is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with Foobar. If not, see . 20 | 21 | Please report bugs to illoul_lounes@yahoo.fr */ 22 | 23 | #pragma once 24 | 25 | //----------------------------------------------------------------------------// 26 | 27 | #include "C_Vec3d.h" 28 | 29 | struct S_Tri_Front 30 | { 31 | long Ind_Arete[3]; 32 | C_Vec3d Normale; 33 | }; 34 | 35 | struct S_Arete_Tri_Front 36 | { 37 | long Ind_Noeud[2]; 38 | long Ind_Tri[2]; 39 | }; 40 | 41 | bool Construction_Topologie_Frontiere 42 | (long Nb_Noeud, double* Tab_Noeud,long Nb_Tri_Front,long* Tab_Ind_Noeud_Tri_Front, 43 | vector* P_List_Tri_Front,vector* P_List_Arete_Tri_Front,double* LAMMTF); 44 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/src/CNEM3D/Global_Header.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/external/cnem_03-10-17/src/CNEM3D/Global_Header.h -------------------------------------------------------------------------------- /external/cnem_03-10-17/src/CNEM3D/GradStabParal.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/external/cnem_03-10-17/src/CNEM3D/GradStabParal.cpp -------------------------------------------------------------------------------- /external/cnem_03-10-17/src/CNEM3D/Groupe_Tet.h: -------------------------------------------------------------------------------- 1 | /* This file is part of CNEMLIB. 2 | 3 | Copyright (C) 2003-2011 4 | Lounes ILLOUL (illoul_lounes@yahoo.fr) 5 | Philippe LORONG (philippe.lorong@ensam.eu) 6 | Arts et Metiers ParisTech, Paris, France 7 | 8 | CNEMLIB is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | CNEMLIB is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with Foobar. If not, see . 20 | 21 | Please report bugs to illoul_lounes@yahoo.fr */ 22 | 23 | #pragma once 24 | 25 | #include "C_Sommet.h" 26 | 27 | void Group_Tet 28 | (int Nb_Tri_Front,int* Tab_Ind_Noeud_Tri_Front,int Nb_Tet,int* Tab_Ind_Noeud_Tet,int* Tab_Ind_V_Tet,int* Tab_Ind_Group_Tet, 29 | bool break_group); 30 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/src/CNEM3D/InterpolParal.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/external/cnem_03-10-17/src/CNEM3D/InterpolParal.cpp -------------------------------------------------------------------------------- /external/cnem_03-10-17/src/CNEM3D/InterpolParal.h: -------------------------------------------------------------------------------- 1 | /* This file is part of CNEMLIB. 2 | 3 | Copyright (C) 2003-2011 4 | Lounes ILLOUL (illoul_lounes@yahoo.fr) 5 | Philippe LORONG (philippe.lorong@ensam.eu) 6 | Arts et Metiers ParisTech, Paris, France 7 | 8 | CNEMLIB is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | CNEMLIB is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with Foobar. If not, see . 20 | 21 | Please report bugs to illoul_lounes@yahoo.fr */ 22 | 23 | #pragma once 24 | 25 | //---------------------------------------------------------------------------// 26 | // Interpolation 3d paralelle 27 | 28 | #include "C_Meshless_3d.h" 29 | 30 | //---------------------------------------------------------------------------// 31 | 32 | void InterpolParal 33 | (C_Meshless_3d* PML,size_t Nb_Point,double* Tab_Point,long Type_FF,long nb_thread, 34 | vector* P_Vec_Ind_Point,vector* P_Vec_Nb_Contrib,vector* P_Vec_INV,vector* P_Vec_Phi,vector* P_Vec_Gard=NULL); 35 | 36 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/src/CNEM3D/interpol_cnem3d.h: -------------------------------------------------------------------------------- 1 | /* This file is part of CNEMLIB. 2 | 3 | Copyright (C) 2003-2011 4 | Lounes ILLOUL (illoul_lounes@yahoo.fr) 5 | Philippe LORONG (philippe.lorong@ensam.eu) 6 | Arts et Metiers ParisTech, Paris, France 7 | 8 | CNEMLIB is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | CNEMLIB is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with Foobar. If not, see . 20 | 21 | Please report bugs to illoul_lounes@yahoo.fr */ 22 | 23 | #pragma once 24 | 25 | #include 26 | using namespace std; 27 | 28 | long interpol_cnem3d 29 | (//IN 30 | size_t Nb_Noeud, 31 | double* Tab_Noeud, 32 | size_t Nb_Tri_Front, 33 | size_t* Tab_Ind_Noeud_Tri_Front, 34 | size_t Nb_Point, 35 | double* Tab_Point, 36 | size_t Type_Appel_Tetgen, 37 | size_t Type_FF, 38 | /*size_t nb_core_for_ff_cal,*/ 39 | //OUT 40 | vector* P_Vec_Ind_Noeud_New_Old, 41 | vector* P_Vec_Ind_Noeud_Old_New, 42 | vector* P_Vec_INVNN, 43 | vector* P_Vec_PNVNN, 44 | vector* P_Vec_Ind_Point, 45 | vector* P_Vec_Nb_Contrib, 46 | vector* P_Vec_INV, 47 | vector* P_Vec_Phi, 48 | vector* P_Vec_Gard); 49 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/src/CNEM3D/mesh_cnem3d.h: -------------------------------------------------------------------------------- 1 | /* This file is part of CNEMLIB. 2 | 3 | Copyright (C) 2003-2011 4 | Lounes ILLOUL (illoul_lounes@yahoo.fr) 5 | Philippe LORONG (philippe.lorong@ensam.eu) 6 | Arts et Metiers ParisTech, Paris, France 7 | 8 | CNEMLIB is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | CNEMLIB is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with Foobar. If not, see . 20 | 21 | Please report bugs to illoul_lounes@yahoo.fr */ 22 | 23 | #pragma once 24 | 25 | #include 26 | using namespace std; 27 | 28 | long mesh_cnem3d 29 | (//IN 30 | size_t Nb_Noeud, 31 | double* Tab_Noeud, 32 | size_t Nb_Tri_Front, 33 | size_t* Tab_Ind_Noeud_Tri_Front, 34 | size_t Type_Appel_Tetgen, 35 | //OUT 36 | vector* P_Vec_Ind_Noeud_New_Old, 37 | vector* P_Vec_Ind_Noeud_Old_New, 38 | vector* P_Vec_New_Noeud, 39 | vector* P_Vec_Ind_Noeud_New_Tri, 40 | vector* P_Vec_Ind_Noeud_Tet); 41 | 42 | 43 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/src/CNEM3D/out_elem_celqt.h: -------------------------------------------------------------------------------- 1 | /* This file is part of CNEMLIB. 2 | 3 | Copyright (C) 2003-2011 4 | Lounes ILLOUL (illoul_lounes@yahoo.fr) 5 | Philippe LORONG (philippe.lorong@ensam.eu) 6 | Arts et Metiers ParisTech, Paris, France 7 | 8 | CNEMLIB is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | CNEMLIB is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with Foobar. If not, see . 20 | 21 | Please report bugs to illoul_lounes@yahoo.fr */ 22 | 23 | #pragma once 24 | 25 | //---------------------------------------------------------------------------// 26 | // 27 | 28 | #include "C_Meshless_3d.h" 29 | 30 | 31 | void out_elem_celqt 32 | (C_Meshless_3d* PML,vector* P_Ind_Voisin_NE,vector* P_Phi_Voisin_NE, 33 | vector* P_Ind_Noeud_Hexa,vector* P_Ind_Cel_Elem_Hexa, 34 | vector* P_Ind_Noeud_Tet,vector* P_Ind_Cel_Elem_Tet, 35 | vector* P_Ind_S_Elem_Tet,vector* P_Id_in_S_Elem_Tet, 36 | vector* P_Coord_Noeud, 37 | vector* P_Nb_Voisin,vector* P_Ind_Voisin,vector* P_Phi_Voisin); 38 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/src/CNEM3D/scni_cnem3d.h: -------------------------------------------------------------------------------- 1 | /* This file is part of CNEMLIB. 2 | 3 | Copyright (C) 2003-2011 4 | Lounes ILLOUL (illoul_lounes@yahoo.fr) 5 | Philippe LORONG (philippe.lorong@ensam.eu) 6 | Arts et Metiers ParisTech, Paris, France 7 | 8 | CNEMLIB is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | CNEMLIB is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with Foobar. If not, see . 20 | 21 | Please report bugs to illoul_lounes@yahoo.fr */ 22 | 23 | #pragma once 24 | 25 | #include 26 | using namespace std; 27 | 28 | long scni_cnem3d 29 | (//IN 30 | size_t Nb_Noeud, 31 | double* Tab_Noeud, 32 | size_t Nb_Tri_Front, 33 | size_t* Tab_Ind_Noeud_Tri_Front, 34 | size_t Type_Appel_Tetgen, 35 | bool Sup_NN_GS, 36 | size_t Type_Int, 37 | size_t Type_FF, 38 | /*size_t nb_core_for_gs_cal,*/ 39 | //OUT 40 | vector* P_Vec_Ind_Noeud_New_Old, 41 | vector* P_Vec_Ind_Noeud_Old_New, 42 | vector* P_Vec_New_Noeud, 43 | vector* P_Vec_INVNN, 44 | vector* P_Vec_PNVNN, 45 | vector* P_Vec_Vol_Cel, 46 | vector* P_Vec_Nb_Contrib, 47 | vector* P_Vec_INV, 48 | vector* P_Vec_Grad, 49 | vector* P_Vec_Ind_Noeud_New_Tri, 50 | vector* P_Vec_Ind_Noeud_Tet); 51 | 52 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/src/TETGEN/README: -------------------------------------------------------------------------------- 1 | This is TetGen version 1.4.3 (released on September 6, 2009, updated on December 13, 2009) 2 | 3 | Please see the documentation of TetGen for compiling and using TetGen. 4 | It is available at the following link: 5 | 6 | http://tetgen.berlios.de/index.html 7 | 8 | TetGen may be freely copied, modified, and redistributed under the 9 | copyright notices stated in the file LICENSE. 10 | 11 | Please send bugs/comments to Hang Si 12 | 13 | Thank you and enjoy! 14 | 15 | Hang Si 16 | December 13, 2009 17 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/src/UTILE/mat_map.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // illoul_amran@yahoo.fr // 4 | // // 5 | // ILLOUL Lounes, LMSP, ENSAM Paris. // 6 | /////////////////////////////////////////////////////////////////////////////// 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | using namespace std; 16 | 17 | struct comp_pos_mat 18 | { 19 | bool operator()(const pair& lhs, const pair& rhs)const 20 | { 21 | if(lhs.first,double,comp_pos_mat> Map_KPL_D; 35 | 36 | struct Mat_Map 37 | { 38 | size_t m_Size; 39 | size_t n_Size; 40 | bool Row_Major; 41 | Map_KPL_D Mat; 42 | }; 43 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/src/UTILE/pnt_gauss_2d.h: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #include 4 | 5 | struct S_Point_de_Gauss 6 | { 7 | double Poids; 8 | double Poids_Position[3]; 9 | }; 10 | 11 | void Initialisation_Point_de_Gauss(vector* List_SPoint_de_Gauss); 12 | -------------------------------------------------------------------------------- /external/cnem_03-10-17/src/UTILE/utile_py.h: -------------------------------------------------------------------------------- 1 | /* This file is part of CNEMLIB. 2 | 3 | Copyright (C) 2003-2011 4 | Lounes ILLOUL (illoul_lounes@yahoo.fr) 5 | Philippe LORONG (philippe.lorong@ensam.eu) 6 | Arts et Metiers ParisTech, Paris, France 7 | 8 | CNEMLIB is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | CNEMLIB is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with Foobar. If not, see . 20 | 21 | Please report bugs to illoul_lounes@yahoo.fr */ 22 | 23 | #pragma once 24 | 25 | #include 26 | #include 27 | using namespace std; 28 | 29 | size_t* Tuple_L_2_Tab_UL(PyObject* Tuple,size_t Size); 30 | double* Tuple_F_2_Tab_D(PyObject* Tuple,size_t Size); 31 | PyObject* Tab_UL_2_Tuple_L(size_t* Tab,size_t Size); 32 | PyObject* Tab_D_2_Tuple_F(double* Tab,size_t Size); 33 | PyObject* Vec_UL_2_Tuple_L(vector* Vec); 34 | PyObject* Vec_D_2_Tuple_F(vector* Vec); 35 | 36 | long Num_2_UL(PyObject* Num); 37 | -------------------------------------------------------------------------------- /external/color_line3/color_line3.m: -------------------------------------------------------------------------------- 1 | function h = color_line3(x, y, z, c, varargin) 2 | % color_line3 plots a 3-D "line" with c-data as color 3 | % 4 | % h = color_line(x, y, z, c) 5 | % by default: 'LineStyle','-' and 'Marker','none' 6 | % 7 | % or 8 | % h = color_line(x, y, z, c, mark) 9 | % or 10 | % h = color_line(x, y, z, c, 'Property','value'...) 11 | % with valid 'Property','value' pairs for a surface object 12 | % 13 | % in: x x-data 14 | % y y-data 15 | % z z-data 16 | % c 4th dimension for colouring 17 | % mark for scatter plots with no connecting line 18 | % 19 | % out: h handle of the surface object 20 | 21 | 22 | h = surface(... 23 | 'XData',[x(:) x(:)],... 24 | 'YData',[y(:) y(:)],... 25 | 'ZData',[z(:) z(:)],... 26 | 'CDataMode', 'auto', ... 27 | 'CData',c,... 28 | 'FaceColor','none',... 29 | 'EdgeColor','interp',... 30 | 'Marker','none'); 31 | 32 | if nargin ==5 33 | switch varargin{1} 34 | case {'+' 'o' '*' '.' 'x' 'square' 'diamond' 'v' '^' '>' '<' 'pentagram' 'p' 'hexagram' 'h'} 35 | set(h,'LineStyle','none','Marker',varargin{1}) 36 | otherwise 37 | error(['Invalid marker: ' varargin{1}]) 38 | end 39 | 40 | elseif nargin > 5 41 | set(h,varargin{:}) 42 | end -------------------------------------------------------------------------------- /external/color_line3/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009, Georg Stillfried 2 | Copyright (c) 2009, Pekka Kumpulainen 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /external/cprintf/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Yair Altman 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution 13 | 14 | * Neither the name of Consultant nor the names of its 15 | contributors may be used to endorse or promote products derived from this 16 | software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /external/quiver3Dpatch/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Kevin Moerman 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /external/simpletracker/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2019, Jean-Yves Tinevez 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /external/tight_subplot/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016, Pekka Kumpulainen 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /io/check_os.m: -------------------------------------------------------------------------------- 1 | function who_am_i = check_os() 2 | % small function to check for os 3 | if ismac 4 | % Code to run on Mac platform 5 | who_am_i = 'apple'; 6 | elseif isunix 7 | % Code to run on Linux platform 8 | who_am_i = 'penguin'; 9 | elseif ispc 10 | % Code to run on Windows platform 11 | who_am_i = 'windows'; 12 | else 13 | disp('Platform not supported') 14 | end 15 | 16 | end % check_os() -------------------------------------------------------------------------------- /io/check_storage_dirs.m: -------------------------------------------------------------------------------- 1 | function input_params = check_storage_dirs(input_params, dir_to_check) 2 | % input: input_params -- struct genereated fromr eadin the input 3 | % configuration json file 4 | 5 | 6 | switch dir_to_check 7 | % Check the directory we use to write partial results during parallel 8 | % execution 9 | 10 | case {'tmp', 'temp', 'temporary', 'temp_files'} 11 | 12 | if ~exist(input_params.general.storage.dir_tmp,'dir') 13 | temp_dir_name = tempdir; % OS specific 14 | input_params.general.storage.dir_tmp = temp_dir_name; 15 | end 16 | case {'output', 'out', 'storage', 'results'} 17 | if ~exist(input_params.general.storage.dir_out, 'dir') 18 | % Check if it doesn't exist because it was an empty string 19 | if strcmp(input_params.general.storage.dir_out, '') 20 | wrn_message = "neural-flows:: Unspecified storage directory for output files"; 21 | else 22 | wrn_message = "neural-flows:: Invalid storage directory for output files. It seems this directory doesn't exist"; 23 | end 24 | warning(wrn_message) 25 | 26 | fprintf('%s \n', strcat('neural-flows:: ', mfilename, '::Info:: Creating scratch/ directory to store results.')) 27 | 28 | % Where is the neural-flows toolbox 29 | [tbx_abs_path] = get_neural_flows_path(); 30 | [yay, ~, ~] = mkdir(tbx_abs_path, 'scratch'); 31 | 32 | if yay 33 | fprintf('%s \n', strcat('neural-flows:: ', mfilename, '::Info:: Succesfully created scratch/ directory to store results.')) 34 | end 35 | end 36 | end 37 | 38 | end % function check_storage_dirs() -------------------------------------------------------------------------------- /io/create_iomat_file.m: -------------------------------------------------------------------------------- 1 | function [mfile_handle, mfile_sentinel] = create_iomat_file(filename, directory, keep_file) 2 | %% Creates a matfile object intended as a temporary file with a pseudorandom 3 | % filename intended as a temporary file. Optionally, it retutrns an OnCleanup 4 | % file sentinel, which will delete the file upon its destruction. 5 | % 6 | % 7 | % ARGUMENTS: 8 | % fname -- string with the 'root' name for that file. Timestamp and 9 | % random string will be appended to it. 10 | % keep_file -- a boolean flag. If one intends to keep the file, then 11 | % mfile_sentinel is an empty array. 12 | % 13 | % OUTPUT: 14 | % mfile_obj -- a Writable matFile() object. 15 | % temp_sentinel -- an OnCleanup object or an empty array, depending 16 | % on the value of keep_file. 17 | % 18 | % REQUIRES: 19 | % generate_temp_filename() 20 | % 21 | % USAGE: 22 | %{ 23 | 24 | %} 25 | % 26 | % AUTHOR: 27 | % Paula Sanz-Leon, QIMR berghofer 2019-02 28 | 29 | mfile_name = generate_temp_filename(filename, 4); 30 | mfile_name = [mfile_name, '.mat']; 31 | mfile_handle = matfile(fullfile(directory, mfile_name), 'Writable', true); 32 | 33 | % Clean up after ourselves 34 | if ~keep_file 35 | mfile_sentinel = onCleanup(@() remove_temp_file(mfile_name)); 36 | else 37 | mfile_sentinel = []; 38 | end 39 | 40 | cprintf('#016500', '%s \n', 'Creating file:') 41 | cprintf('Black', '\t %s \n', mfile_name) 42 | end % function create_iomat_file() 43 | 44 | function remove_temp_file(fname) 45 | % This action will be performed when 46 | % mfile_sentinel is destroyed 47 | 48 | cprintf('Red', '%s \n', 'Removing file:') 49 | cprintf('Black', '\t %s \n', fname) 50 | delete(fname) 51 | 52 | end % function remove_temp_file() 53 | -------------------------------------------------------------------------------- /io/generate_slice_filename.m: -------------------------------------------------------------------------------- 1 | function params = generate_slice_filename(params, field_name) 2 | % TODO: document 3 | 4 | tmp_str = ['tmp_' field_name]; 5 | 6 | if eval(['isfield(params.' [field_name] '.file, "label")']) 7 | slice_str = ['-' tmp_str '-' num2str(params.data.slice.id, '%03d')]; 8 | eval(['root_fname = [params.' field_name '.file.label slice_str]' ]) 9 | else 10 | root_fname = [tmp_str '-' num2str(params.data.slice.id, '%03d')]; 11 | end 12 | eval(['params.' field_name '.file.label = root_fname']); 13 | 14 | end % function generate_slice_filename() 15 | -------------------------------------------------------------------------------- /io/generate_temp_filename.m: -------------------------------------------------------------------------------- 1 | function temp_fname = generate_temp_filename(root_fname, seq_len) 2 | %% This function generates a temp filename by appending a timestamp and a 3 | % sequence of random letters to the root filename given as input argument 4 | % The timestamp follows ISO 8601 format as 'yyyy-mm-dd_HH-MM-SS' 5 | % 6 | % ARGUMENTS: 7 | % root_fname -- a string with the root filename 8 | % seq_len -- an integer. The length of a string with a random 9 | % sequence of characters appended to root_fname 10 | % 11 | % OUTPUT: 12 | % temp_fname -- a string with the temporary/pseudorandom filename 13 | % built as strcat(root_fname, '_', timestamp_str, '_', random_str) 14 | % 15 | % REQUIRES: 16 | % none 17 | % 18 | % USAGE: 19 | %{ 20 | root_fname = 'my_temp_file'; 21 | temp_fname = generate_temp_filename(root_fname, 3); 22 | %} 23 | % 24 | % AUTHOR: 25 | % Paula Sanz-Leon, QIMR Berghofer, 2019- 26 | % TODO: may need to give the format ending (eg, txt, mat, ) as input cause 27 | % some functions need that bit 28 | 29 | if nargin < 2 30 | seq_len = 4; 31 | end 32 | 33 | timestamp_str = datestr(now, 'yyyy-mm-dd_HH-MM-SS-FFF'); 34 | random_str = random_char_seq(seq_len); 35 | temp_fname = strcat(root_fname, '_', timestamp_str, '_', random_str); 36 | 37 | end % function generate_temp_filename() 38 | 39 | 40 | function char_seq = random_char_seq(seq_len) 41 | 42 | alphabet = strcat('A':'Z', 'a':'z'); 43 | char_seq = alphabet(randi(numel(alphabet), [seq_len, 1])); 44 | 45 | end % function generate char_seq() 46 | -------------------------------------------------------------------------------- /io/get_directory_path.m: -------------------------------------------------------------------------------- 1 | function path_to_dir = get_directory_path(full_path_to_exec_file, dir_path) 2 | 3 | C = strsplit(full_path_to_exec_file, filesep); 4 | O = strcat(C(1:end-1), filesep); 5 | path_to_dir = strcat(O{:}, dir_path); 6 | 7 | end -------------------------------------------------------------------------------- /io/get_neural_flows_path.m: -------------------------------------------------------------------------------- 1 | function [tbx_abs_path] = get_neural_flows_path() 2 | % Small function to get absolute path to where the neural-flows toolbox is 3 | % located. 4 | % Returns the OS specific absolute path to the toolbox 5 | 6 | % PSL, July 2020 7 | 8 | % where am I 9 | 10 | [filepath, ~, ~] = fileparts(mfilename('fullpath')); 11 | 12 | split_file_path = strsplit(filepath, filesep); 13 | 14 | who_am_i = check_os(); 15 | 16 | if strcmp(who_am_i, 'penguin') 17 | tbx_abs_path = [filesep strjoin(split_file_path(2:end-1), filesep)]; 18 | elseif strcmp(who_am_i, 'apple') 19 | tbx_abs_path = [filesep strjoin(split_file_path(2:end-1), filesep)]; 20 | else 21 | tbx_abs_path = strjoin(split_file_path(1:end-1), filesep); 22 | end % 23 | 24 | end % get_neural_flows_path() -------------------------------------------------------------------------------- /io/load_iomat_flows.m: -------------------------------------------------------------------------------- 1 | function [obj_flows, varargout] = load_iomat_flows(params) 2 | % Load flow data 3 | obj_flows = matfile(fullfile(params.flows.file.dir, ... 4 | params.flows.file.name), ... 5 | 'Writable', false); 6 | 7 | end % function load_iomat_flows() -------------------------------------------------------------------------------- /io/load_iomat_interp.m: -------------------------------------------------------------------------------- 1 | function [obj_data, obj_data_sentinel] = load_iomat_interp(params) 2 | % Load interpolated data iomat 3 | 4 | % Load file with interpolated datafile 5 | obj_data = matfile(fullfile(params.interpolation.file.dir, ... 6 | params.interpolation.file.name), ... 7 | 'Writable', false); 8 | 9 | 10 | 11 | end % function load_iomat_interp() -------------------------------------------------------------------------------- /io/load_iomat_singularity.m: -------------------------------------------------------------------------------- 1 | function [obj_singularity, varargout] = load_iomat_singularity(params) 2 | 3 | % Load flow data 4 | obj_singularity = matfile(fullfile(params.singularity.file.dir, ... 5 | params.singularity.file.name), ... 6 | 'Writable', true); 7 | 8 | end % function load_iomat_singularity() -------------------------------------------------------------------------------- /io/load_iomat_streams.m: -------------------------------------------------------------------------------- 1 | function [obj_streams, varargout] = load_iomat_flows(params) 2 | % Load flow data 3 | obj_streams = matfile(fullfile(params.streamlines.file.dir, ... 4 | params.streamlines.file.name), ... 5 | 'Writable', false); 6 | 7 | end % function load_iomat_streams() -------------------------------------------------------------------------------- /io/open_parpool.m: -------------------------------------------------------------------------------- 1 | function open_parpool(workers_proportion) 2 | %% This function first checks if there is a parallel pool open, 3 | % then opens one pool if none exist. If there is a pool open, it deletes it 4 | % and opens a new one wuth the requested proportion of workers. 5 | % The number of workers in the new pool is determined based 6 | % on the hardware and the proportion specified in the input. 7 | % 8 | % ARGUMENTS: 9 | % workers_proportion -- a number > 0 or <=1 (ideally 0.25, 0.5, 0.8) 10 | % specifying the proportion of workers that the 11 | % parallel pool will have available. 12 | % 13 | % OUTPUT: 14 | % none 15 | % 16 | % REQUIRES: 17 | % Matlab's parallel computing toolbox 18 | % 19 | % USAGE: 20 | %{ 21 | open_parpool(0.5) % uses half of the physically available workers 22 | %} 23 | % AUTHOR: 24 | % Paula Sanz-Leon, QIMR Berghofer 2019 25 | % 26 | 27 | p = gcp('nocreate'); 28 | % If the parpool is not empty, then deletes the current parppol and 29 | % opens a new one with the requested proportion of workers. 30 | if ~isempty(p) 31 | delete(p); 32 | end 33 | 34 | my_cluster = parcluster('local'); 35 | num_workers = round(workers_proportion*my_cluster.NumWorkers); 36 | 37 | if num_workers > 0 38 | parpool(num_workers, 'IdleTimeout', Inf); 39 | else 40 | error('Cannot open parpool with zero workers') 41 | end 42 | end % function open_parpool() 43 | -------------------------------------------------------------------------------- /io/save_params_checkpoint.m: -------------------------------------------------------------------------------- 1 | function save_params_checkpoint(tmp_params) 2 | % Dummy function that saves json output params up to a point in the code 3 | % Downside - it ovewrites the file if it exists 4 | read_write_json(tmp_params.general.params.output.file.name, ... 5 | tmp_params.general.params.output.file.dir, ... 6 | 'write', ... 7 | tmp_params) 8 | 9 | end -------------------------------------------------------------------------------- /startup.m: -------------------------------------------------------------------------------- 1 | % Add neural-flows modules to path at startup, provided we are not 2 | % invoking the compiler(mcc) or running a deployed instance. 3 | if ~(ismcc || isdeployed) 4 | fprintf('%s \n', strcat('neural-flows:: ', mfilename, '::Info:: Adding neural-flows folders to Matlab''s path.')) 5 | % Add main modules 6 | addpath('io', '-begin'); 7 | addpath('core', '-begin'); 8 | addpath('analysis', '-begin'); 9 | addpath('visualisation', '-begin'); 10 | % Add ancilliary modules 11 | addpath('utils', '-begin'); 12 | addpath('utils/calc', '-begin'); 13 | addpath('utils/misc', '-begin'); 14 | addpath('utils/signal', '-begin'); 15 | addpath('utils/vis', '-begin'); 16 | addpath('utils/vis/colourmaps', '-begin'); 17 | % Add data 18 | addpath('demo-data', '-begin'); 19 | % Add examples 20 | addpath('examples', '-begin'); 21 | % Add external modules 22 | addpath(genpath('external'), '-begin'); 23 | % Add top directory 24 | addpath('../neural-flows/', '-begin'); 25 | display_toolbox_name() 26 | fprintf('%s \n', strcat('neural-flows:: ', mfilename, '::Info:: Done!')) 27 | end 28 | % end of startup() -------------------------------------------------------------------------------- /tests/data/data-biharmonic-wave-structured-iomat.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/tests/data/data-biharmonic-wave-structured-iomat.mat -------------------------------------------------------------------------------- /tests/data/data-biharmonic-wave-unstructured-iomat.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/tests/data/data-biharmonic-wave-unstructured-iomat.mat -------------------------------------------------------------------------------- /tests/data/data-biharmonic-wave-unstructured.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/tests/data/data-biharmonic-wave-unstructured.mat -------------------------------------------------------------------------------- /tests/data/data-plane-wave-structured-iomat.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/tests/data/data-plane-wave-structured-iomat.mat -------------------------------------------------------------------------------- /tests/data/data-plane-wave-unstructured-iomat.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/tests/data/data-plane-wave-unstructured-iomat.mat -------------------------------------------------------------------------------- /tests/data/data-plane-wave-unstructured.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/tests/data/data-plane-wave-unstructured.mat -------------------------------------------------------------------------------- /tests/data/data-spiral-wave-structured-iomat.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/tests/data/data-spiral-wave-structured-iomat.mat -------------------------------------------------------------------------------- /tests/data/data-spiral-wave-unstructured-iomat.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/tests/data/data-spiral-wave-unstructured-iomat.mat -------------------------------------------------------------------------------- /tests/data/data-spiral-wave-unstructured.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/tests/data/data-spiral-wave-unstructured.mat -------------------------------------------------------------------------------- /tests/data/data-travelling-wave-structured-iomat.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/tests/data/data-travelling-wave-structured-iomat.mat -------------------------------------------------------------------------------- /tests/data/data-travelling-wave-unstructured-iomat.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/tests/data/data-travelling-wave-unstructured-iomat.mat -------------------------------------------------------------------------------- /tests/data/data-travelling-wave-unstructured.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/tests/data/data-travelling-wave-unstructured.mat -------------------------------------------------------------------------------- /tests/generate/generate_flows3d_burgesvortex.m: -------------------------------------------------------------------------------- 1 | function [ux, uy, uz] = generate_flows3d_burgesvortex() 2 | % ARGUMENTS: 3 | % None 4 | % OUTPUT: 5 | % [ux, uy, uz] -- orthogonal velocity field components of size [ny, nx, nz] 6 | % 7 | % USAGE: 8 | %{ 9 | 10 | %} 11 | % AUTHOR: 12 | % Paula Sanz-Leon June 2019 13 | % 14 | % REFERENCE: 15 | % https://aip.scitation.org/doi/full/10.1063/1.4893343 16 | % Analytic solutions for three dimensional swirling strength in compressible and incompressible flows 17 | % Eq (12) 18 | 19 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 20 | 21 | alfa = 0.2; % strain-rate 22 | gmma = 0.1; % circulation 23 | nu = 0.1; % kinematic viscosity 24 | ro = sqrt(4*nu/alfa); % core radius 25 | omegaz = gmma/(pi*ro^2); % spanwise vorticity 26 | 27 | 28 | x = linspace(-5, 5, 21); 29 | [X, Y, Z] = meshgrid(x, x, x); 30 | R = X.^2+Y.^2; 31 | 32 | ux = -alfa/2.*X + ... 33 | gmma/(2*pi).*(1-exp(-R./((4*nu)/alfa))) .* (1./R) .* -Y; 34 | uy = -alfa/2.*Y + ... 35 | gmma/(2*pi).*(1-exp(-R./((4*nu)/alfa))) .* (1./R) .* X; 36 | uz = alfa .* Z; 37 | 38 | fig_handle = figure('Name', 'nflows-burges'); 39 | unorm = sqrt(ux.^2 + uy.^2 + uz.^2); 40 | hcone = coneplot(X, Y, Z, ux, uy, uz, X, Y, Z, unorm); 41 | set(hcone,'EdgeColor','none'); 42 | camlight right 43 | lighting gouraud 44 | 45 | hcone.DiffuseStrength = 0.8; 46 | 47 | end % function generate_flow3d_burgesvortex_grid() -------------------------------------------------------------------------------- /tests/generate/generate_flows3d_embeddedvortex.m: -------------------------------------------------------------------------------- 1 | function [ux, uy, uz] = generate_flows3d_embeddedvortex() 2 | % ARGUMENTS: 3 | % None 4 | % OUTPUT: 5 | % [ux, uy, uz] -- orthogonal velocity field components of size [ny, nx, nz] 6 | % 7 | % USAGE: 8 | %{ 9 | 10 | %} 11 | % AUTHOR: 12 | % Paula Sanz-Leon June 2019 13 | % 14 | % REFERENCE: 15 | % https://www.groundai.com/project/vortex-dynamics-in-cerebral-aneurysms/1 16 | % Eq (2) 17 | % A maximum of two fixed points, located at xf1=(−√R,0,0) and xf2=(√R,0,0), 18 | 19 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 20 | 21 | A = -5; 22 | B = 0.2; 23 | 24 | x = linspace(-5, 5, 21); 25 | [X, Y, Z] = meshgrid(x, x, x); 26 | R = 1; 27 | 28 | ux = Y; 29 | uy = Z; 30 | G1 = X.^2 - R; 31 | G2 = A.*Y + B.*Z.^2; 32 | uz = G1 + G2; 33 | 34 | fig_handle = figure('Name', 'nflows-abcflow'); 35 | unorm = sqrt(ux.^2 + uy.^2 + uz.^2); 36 | hcone = coneplot(X, Y, Z, ux, uy, uz, X, Y, Z, unorm); 37 | set(hcone,'EdgeColor','none'); 38 | camlight right 39 | lighting gouraud 40 | 41 | hcone.DiffuseStrength = 0.8; 42 | 43 | end % function generate_embeddedvortex_3d_structured() -------------------------------------------------------------------------------- /tests/test_flows3d_estimation__plane_wave_sah.m: -------------------------------------------------------------------------------- 1 | function test_flows3d_estimation__plane_wave_sah() 2 | % Estimate amplitude-based flows of a plane wave using Horn-Schunk 3D algorithm. 3 | % The wave is defined on an structured domain (ie, regular grid). 4 | % This is a plane wave moving at 2 m/s in the y-direction 5 | % NOTE: Assumes this function is called from tests/ directory 6 | 7 | % | | Data Domain | Data Mode | Flow Method | 8 | % |-----|----------------|-------------|-----------------| 9 | % | sah | (s)tructured | (a)mplitude | (h)orn-schunk3d | 10 | 11 | input_params = read_write_json('test-flows3d-estimation_plane-wave_sah_in.json', 'json/', 'read'); 12 | 13 | output_params = main(input_params); 14 | 15 | [obj_flows] = load_iomat_flows(output_params); 16 | 17 | % Plot stuff 18 | fig_hist = figure('Name', mfilename); 19 | 20 | plot_debug_flow_histogram(fig_hist, obj_flows, output_params) 21 | 22 | end % function test_flows3d_estimation__plane_wave_sah() 23 | -------------------------------------------------------------------------------- /tests/test_flows3d_estimation__plane_wave_uac.m: -------------------------------------------------------------------------------- 1 | function test_flows3d_estimation__plane_wave_uac() 2 | % Estimate amplitude-based flows of a plane wave using CNEM library. 3 | % The wave is defined on an unstructured domain (ie, scattered points). 4 | % This is a plane wave moving at 2 m/s in the y-direction 5 | % NOTE: Assumes this function is called from tests/ directory 6 | 7 | %| | Data Domain | Data Mode | Flow Method | 8 | %|-----|----------------|-------------|-----------------| 9 | %| uac | (u)nstructured | (a)mplitude | (c)nem | 10 | 11 | input_params = read_write_json('test-flows3d-estimation_plane-wave_uac_in.json', 'json/', 'read'); 12 | 13 | output_params = main(input_params); 14 | 15 | [obj_flows] = load_iomat_flows(output_params); 16 | 17 | % Plot stuff 18 | fig_hist = figure('Name', mfilename); 19 | 20 | plot_debug_flow_histogram(fig_hist, obj_flows, output_params) 21 | 22 | end % test_flows3d_estimation__plane_wave_uac() 23 | -------------------------------------------------------------------------------- /tests/test_flows3d_estimation__plane_wave_uah.m: -------------------------------------------------------------------------------- 1 | function test_flows3d_estimation__plane_wave_uah() 2 | % Estimate amplitude-based flows of a plane wave using Husing Horn-Schunk 3D algorithm. 3 | % The wave is defined on an unstructured domain (ie, scattered points). 4 | % This is a plane wave moving at 2 m/s in the y-direction 5 | % NOTE: Assumes this function is called from tests/ directory 6 | 7 | % | | Data Domain | Data Mode | Flow Method | 8 | % |-----|----------------|-------------|-----------------| 9 | % | uah | (u)nstructured | (a)mplitude | (h)orn-schunk3d | 10 | 11 | input_params = read_write_json('test-flows3d-estimation_plane-wave_uah_in.json', 'json/', 'read'); 12 | 13 | output_params = main(input_params); 14 | 15 | [obj_flows] = load_iomat_flows(output_params); 16 | 17 | % Plot stuff 18 | fig_hist = figure('Name', mfilename); 19 | 20 | plot_debug_flow_histogram(fig_hist, obj_flows, output_params) 21 | 22 | end % test_flows3d_estimation__plane_wave_uah 23 | -------------------------------------------------------------------------------- /tests/test_flows3d_estimation__plane_wave_upc.m: -------------------------------------------------------------------------------- 1 | function test_flows3d_estimation__plane_wave_upc() 2 | %% Estimate phase-based flows of a plane wave using CNEM library, 3 | % and Roberts et al. 2019 method. 4 | % The wave is defined on an unstructured domain (ie, scattered points). 5 | % This is a wave moving at 2 m/s in the y-direction. 6 | % NOTE: Assumes this function is called from tests/ directory 7 | 8 | % | | Data Domain | Data Mode | Flow Method | 9 | % |-----|----------------|-------------|-----------------| 10 | % | upc | (u)nstructured | (p)hase | (c)nem | 11 | 12 | input_params = read_write_json('test-flows3d-estimation_plane-wave_upc_in.json', 'json/', 'read'); 13 | 14 | output_params = main(input_params); 15 | 16 | [obj_flows] = load_iomat_flows(output_params); 17 | 18 | % Plot stuff 19 | fig_hist = figure('Name', mfilename); 20 | 21 | plot_debug_flow_histogram(fig_hist, obj_flows, output_params) 22 | 23 | end % function test_flows3d_estimation__plane_wave_upc() 24 | -------------------------------------------------------------------------------- /tests/test_flows3d_estimation__spiral_wave_sah.m: -------------------------------------------------------------------------------- 1 | function test_flows3d_estimation__spiral_wave_sah() 2 | % Estimate amplitude-based flows of a spiral wave using Horn-Schunk 3D algorithm. 3 | 4 | % NOTE: Assumes this function is called from tests/ directory 5 | 6 | % | | Data Domain | Data Mode | Flow Method | 7 | % |-----|----------------|-------------|-----------------| 8 | % | sah | (s)tructured | (a)mplitude | (h)orn-schunk3d | 9 | 10 | input_params = read_write_json('test-flows3d-estimation_spiral-wave_sah_in.json', 'json/', 'read'); 11 | 12 | output_params = main(input_params); 13 | 14 | [obj_flows] = load_iomat_flows(output_params); 15 | 16 | % Plot stuff 17 | fig_hist = figure('Name', mfilename); 18 | 19 | plot_debug_flow_histogram(fig_hist, obj_flows, output_params) 20 | 21 | end % function test_flows3d_estimation__spiral_wave_sah() 22 | -------------------------------------------------------------------------------- /tests/test_flows3d_estimation__spiral_wave_uac.m: -------------------------------------------------------------------------------- 1 | function test_flows3d_estimation__spiral_wave_uac() 2 | % Estimate amplitude-based flows of a spiral wave using CNEM library. 3 | % The wave is defined on an unstructured domain (ie, scattered points). 4 | 5 | % NOTE: Assumes this function is called from tests/ directory 6 | 7 | %| | Data Domain | Data Mode | Flow Method | 8 | %|-----|----------------|-------------|-----------------| 9 | %| uac | (u)nstructured | (a)mplitude | (c)nem | 10 | 11 | input_params = read_write_json('test-flows3d-estimation_spiral-wave_uac_in.json', 'json/', 'read'); 12 | 13 | output_params = main(input_params); 14 | 15 | [obj_flows] = load_iomat_flows(output_params); 16 | 17 | % Plot stuff 18 | fig_hist = figure('Name', mfilename); 19 | 20 | plot_debug_flow_histogram(fig_hist, obj_flows, output_params) 21 | 22 | end % test_flows3d_estimation__spiral_wave_uac() 23 | -------------------------------------------------------------------------------- /tests/test_flows3d_estimation__spiral_wave_uah.m: -------------------------------------------------------------------------------- 1 | function test_flows3d_estimation__spiral_wave_uah() 2 | % Estimate amplitude-based flows of a spiral wave using Horn-Schunk 3D algorithm. 3 | % NOTE: Assumes this function is called from tests/ directory 4 | 5 | % | | Data Domain | Data Mode | Flow Method | 6 | % |-----|----------------|-------------|-----------------| 7 | % | uah | (u)nstructured | (a)mplitude | (h)orn-schunk3d | 8 | 9 | input_params = read_write_json('test-flows3d-estimation_spiral-wave_uah_in.json', 'json/', 'read'); 10 | 11 | output_params = main(input_params); 12 | 13 | [obj_flows] = load_iomat_flows(output_params); 14 | 15 | % Plot stuff 16 | fig_hist = figure('Name', mfilename); 17 | 18 | plot_debug_flow_histogram(fig_hist, obj_flows, output_params) 19 | end % function test_flows3d_estimation__spiral_wave_uah() 20 | -------------------------------------------------------------------------------- /tests/test_flows3d_estimation__spiral_wave_upc.m: -------------------------------------------------------------------------------- 1 | function test_flows3d_estimation__spiral_wave_upc() 2 | % Estimate phase-based flows of a spiral wave using CNEM library, 3 | % and Roberts et al. 2019 method. 4 | 5 | % NOTE: Assumes this function is called from tests/ directory 6 | 7 | input_params = read_write_json('test-flows3d-estimation_spiral-wave_upc_in.json', 'json/', 'read'); 8 | 9 | output_params = main(input_params); 10 | 11 | [obj_flows] = load_iomat_flows(output_params); 12 | 13 | % Plot stuff 14 | fig_hist = figure('Name', mfilename); 15 | 16 | plot_debug_flow_histogram(fig_hist, obj_flows, output_params) 17 | 18 | end % function test_flows3d_estimation__spiral_wave_upc() 19 | -------------------------------------------------------------------------------- /tests/test_flows3d_estimation__travelling_biharmonic_wave_sah.m: -------------------------------------------------------------------------------- 1 | function test_flows3d_estimation__travelling_biharmonic_wave_sah() 2 | % This is a travelling biharmonic wave (ie, composed of two sine waves 3 | % at slightly different frequencies). The group velocity and phase velocity have opposite 4 | % orientation. 5 | 6 | % NOTE: Assumes this function is called from tests/ directory 7 | 8 | % | | Data Domain | Data Mode | Flow Method | 9 | % |-----|----------------|-------------|-----------------| 10 | % | sah | (s)tructured | (a)mplitude | (h)orn-schunk3d | 11 | 12 | input_params = read_write_json('test-flows3d-estimation_biharmonic-wave_sah_in.json', 'json/', 'read'); 13 | 14 | output_params = main(input_params); 15 | 16 | [obj_flows] = load_iomat_flows(output_params); 17 | 18 | % Plot stuff 19 | fig_hist = figure('Name', mfilename); 20 | 21 | plot_debug_flow_histogram(fig_hist, obj_flows, output_params) 22 | 23 | end % function test_flows3d_estimation__travelling_biharmonic_wave_sah() 24 | plo -------------------------------------------------------------------------------- /tests/test_flows3d_estimation__travelling_biharmonic_wave_uac.m: -------------------------------------------------------------------------------- 1 | function test_flows3d_estimation__travelling_biharmonic_wave_uac() 2 | % This is a travelling biharmonic wave (ie, composed of two sine waves 3 | % at slightly different frequencies). The group velocity and phase velocity have opposite 4 | % orientation. 5 | 6 | % NOTE: Assumes this function is called from tests/ directory 7 | 8 | %| | Data Domain | Data Mode | Flow Method | 9 | %|-----|----------------|-------------|-----------------| 10 | %| uac | (u)nstructured | (a)mplitude | (c)nem | 11 | 12 | input_params = read_write_json('test-flows3d-estimation_biharmonic-wave_uac_in.json', 'json/', 'read'); 13 | 14 | output_params = main(input_params); 15 | 16 | [obj_flows] = load_iomat_flows(output_params); 17 | 18 | % Plot stuff 19 | fig_hist = figure('Name', mfilename); 20 | 21 | plot_debug_flow_histogram(fig_hist, obj_flows, output_params); 22 | 23 | end % function test_flows3d_estimation__travelling_biharmonic_wave_uac() 24 | -------------------------------------------------------------------------------- /tests/test_flows3d_estimation__travelling_biharmonic_wave_uah.m: -------------------------------------------------------------------------------- 1 | function test_flows3d_estimation__travelling_biharmonic_wave_uah() 2 | % This is a travelling biharmonic wave (ie, composed of two sine waves 3 | % at slightly different frequencies). The group velocity and phase velocity have opposite 4 | % orientation. 5 | 6 | % NOTE: Assumes this function is called from tests/ directory 7 | 8 | % | | Data Domain | Data Mode | Flow Method | 9 | % |-----|----------------|-------------|-----------------| 10 | % | uah | (u)nstructured | (a)mplitude | (h)orn-schunk3d | 11 | 12 | input_params = read_write_json('test-flows3d-estimation_biharmonic-wave_uah_in.json', 'json/', 'read'); 13 | 14 | output_params = main(input_params); 15 | 16 | [obj_flows] = load_iomat_flows(output_params); 17 | 18 | % Plot stuff 19 | fig_hist = figure('Name', mfilename); 20 | 21 | plot_debug_flow_histogram(fig_hist, obj_flows, output_params); 22 | 23 | end % function test_flows3d_estimation__travelling_biharmonic_wave_uah() 24 | -------------------------------------------------------------------------------- /tests/test_flows3d_estimation__travelling_biharmonic_wave_upc.m: -------------------------------------------------------------------------------- 1 | function test_flows3d_estimation__travelling_biharmonic_wave_upc() 2 | % This is a travelling biharmonic wave (ie, composed of two sine waves 3 | % at slightly different frequencies). The group velocity and phase velocity have opposite 4 | % orientation. 5 | 6 | % NOTE: Assumes this function is called from tests/ directory 7 | 8 | % | | Data Domain | Data Mode | Flow Method | 9 | % |-----|----------------|-------------|-----------------| 10 | % | upc | (u)nstructured | (p)hase | (c)nem | 11 | 12 | input_params = read_write_json('test-flows3d-estimation_biharmonic-wave_upc_in.json', 'json/', 'read'); 13 | 14 | output_params = main(input_params); 15 | 16 | [obj_flows] = load_iomat_flows(output_params); 17 | 18 | % Plot stuff 19 | fig_hist = figure('Name', mfilename); 20 | 21 | plot_debug_flow_histogram(fig_hist, obj_flows, output_params); 22 | 23 | end % function test_flows3d_estimation__travelling_biharmonic_wave_uac() 24 | -------------------------------------------------------------------------------- /tests/test_flows3d_estimation__travelling_wave_sah.m: -------------------------------------------------------------------------------- 1 | function test_flows3d_estimation__travelling_wave_sah() 2 | % Estimate amplitude-based flows of a travelling wave using Horn-Schunk 3D algorithm. 3 | % The wave is defined on a structured domain (ie, regular grid). 4 | % This is a wave moving at 4 m/s in the y-direction, and then travelling 5 | % back in the same direction but opposite orientation (- 4 m/s) 6 | % NOTE: Assumes this function is called from tests/ directory 7 | 8 | % | | Data Domain | Data Mode | Flow Method | 9 | % |-----|----------------|-------------|-----------------| 10 | % | sah | (s)tructured | (a)mplitude | (h)orn-schunk3d | 11 | 12 | input_params = read_write_json('test-flows3d-estimation_travelling-wave_sah_in.json', 'json/', 'read'); 13 | 14 | output_params = main(input_params); 15 | 16 | [obj_flows] = load_iomat_flows(output_params); 17 | 18 | % Plot stuff 19 | fig_hist = figure('Name', mfilename); 20 | 21 | plot_debug_flow_histogram(fig_hist, obj_flows, output_params) 22 | 23 | end % function test_flows3d_estimation__travelling_wave_sah() 24 | -------------------------------------------------------------------------------- /tests/test_flows3d_estimation__travelling_wave_uac.m: -------------------------------------------------------------------------------- 1 | function test_flows3d_estimation__travelling_wave_uac() 2 | %% Estimate amplitude-based flows of a travelling wave using CNEM library. 3 | % The wave is defined on an unstructured domain (ie, scattered points). 4 | % This is a wave moving at 4 m/s in the y-direction, and then travelling 5 | % back in the same direction but opposite orientation (- 4 m/s) 6 | % NOTE: Assumes this function is called from tests/ directory 7 | 8 | %| | Data Domain | Data Mode | Flow Method | 9 | %|-----|----------------|-------------|-----------------| 10 | %| uac | (u)nstructured | (a)mplitude | (c)nem | 11 | 12 | input_params = read_write_json('test-flows3d-estimation_travelling-wave_uac_in.json', 'json/', 'read'); 13 | 14 | output_params = main(input_params); 15 | 16 | [obj_flows] = load_iomat_flows(output_params); 17 | 18 | % Plot stuff 19 | fig_hist = figure('Name', mfilename); 20 | 21 | plot_debug_flow_histogram(fig_hist, obj_flows, output_params) 22 | end % function test_flows3d_estimation__travelling_wave_uac() -------------------------------------------------------------------------------- /tests/test_flows3d_estimation__travelling_wave_uah.m: -------------------------------------------------------------------------------- 1 | function test_flows3d_estimation__travelling_wave_uah() 2 | % Estimate amplitude-based flows of a travelling wave using Horn-Schunk 3D algorithm. 3 | % The wave is defined on an unstructured domain (ie, scattered points). 4 | % This is a wave moving at 4 m/s in the y-direction, and then travelling 5 | % back in the same direction but opposite orientation (- 4 m/s) 6 | % NOTE: Assumes this function is called from tests/ directory 7 | 8 | % | | Data Domain | Data Mode | Flow Method | 9 | % |-----|----------------|-------------|-----------------| 10 | % | uah | (u)nstructured | (a)mplitude | (h)orn-schunk3d | 11 | 12 | input_params = read_write_json('test-flows3d-estimation_travelling-wave_uah_in.json', 'configs/', 'read'); 13 | 14 | output_params = main_core(input_params); 15 | 16 | [obj_flows] = load_iomat_flows(output_params); 17 | 18 | % Plot stuff 19 | fig_hist = figure('Name', mfilename); 20 | 21 | plot_debug_flow_histogram(fig_hist, obj_flows, output_params) 22 | 23 | end % function test_flows3d_estimation__travelling_wave_uah -------------------------------------------------------------------------------- /tests/test_flows3d_estimation__travelling_wave_upc.m: -------------------------------------------------------------------------------- 1 | function test_flows3d_estimation__travelling_wave_upc() 2 | %% Estimate phase-based flows of a travelling wave using CNEM library, 3 | % and Roberts et al. 2019 method. 4 | % The wave is defined on an unstructured domain (ie, scattered points). 5 | % This is a wave moving at 4 m/s in the y-direction, and then travelling 6 | % back in the same direction but opposite orientation (- 4 m/s) 7 | % NOTE: Assumes this function is called from tests/ directory 8 | 9 | % | | Data Domain | Data Mode | Flow Method | 10 | % |-----|----------------|-------------|-----------------| 11 | % | upc | (u)nstructured | (p)hase | (c)nem | 12 | 13 | input_params = read_write_json('test-flows3d-estimation_travelling-wave_upc_in.json', 'json/', 'read'); 14 | 15 | output_params = main(input_params); 16 | 17 | [obj_flows] = load_iomat_flows(output_params); 18 | 19 | % Plot stuff 20 | fig_hist = figure('Name', mfilename); 21 | 22 | plot_debug_flow_histogram(fig_hist, obj_flows, output_params) 23 | 24 | end % function test_flows3d_estimation__travelling_wave_upc() -------------------------------------------------------------------------------- /tests/test_performance_rotating_wave.m: -------------------------------------------------------------------------------- 1 | function run_times = test_performance_rotating_wave(num_iterations) 2 | % This script runs the core stages on a small epoch of simulated data 3 | 4 | if nargin < 1 5 | num_iterations = 8; 6 | end 7 | 8 | input_params_filename = 'rotating_wave_uah_in.json'; 9 | input_params_dir = 'examples/configs'; 10 | json_mode = 'read'; 11 | 12 | %% Load configuration file with options 13 | input_params = read_write_json(input_params_filename, input_params_dir, json_mode); 14 | 15 | %% Check that the input tmp folder and output folder exist and are consistent with OS, 16 | % if they aren't, it will try to fix the problem, or error 17 | input_params = check_storage_dirs(input_params, 'temp'); 18 | input_params = check_storage_dirs(input_params, 'output'); 19 | 20 | %% Run core functions: interpolation, estimation and classification, streamlines, this function writes to a new json file 21 | run_times = zeros(num_iterations, 1); 22 | for this_iteration = 1:num_iterations 23 | fprintf('%s \n', strcat('neural-flows:: ', mfilename, '::Info:: START RUN.')) 24 | tstart = tik(); 25 | main_core(input_params); 26 | fprintf('%s \n', strcat('neural-flows:: ', mfilename, '::Info:: END RUN.')) 27 | run_times(this_iteration) = tok(tstart, 'minutes'); 28 | end 29 | end %test_performance_rotating_wave() -------------------------------------------------------------------------------- /tests/test_singularity3d_detection__abc_flow.m: -------------------------------------------------------------------------------- 1 | function test_singularity3d_detection__abc_flow() 2 | % Generates a single flow frame 3 | % 4 | % ARGUMENTS: 5 | % OUTPUT: 6 | % None 7 | % 8 | % REQUIRES: 9 | % 10 | % USAGE: 11 | %{ 12 | 13 | %} 14 | % 15 | % MODIFICATION HISTORY: 16 | % Paula Sanz-Leon -- QIMR October 2019 17 | % REFERENCES: 18 | % Didov, Ulysky (2018) Analysis of stationary points and their bifurcations in the ABC flow 19 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 20 | 21 | 22 | 23 | end %function test_singularity3d_detection__abc_flow() 24 | -------------------------------------------------------------------------------- /utils/calc/apply_spatiotemporal_mask.m: -------------------------------------------------------------------------------- 1 | function wave = apply_spatiotemporal_mask(wave, Aspace, Atime) 2 | % spatiotemporal_masks. Apply separate spatial and temporal amplitude 3 | % profiles to a wave 2D+t pattern 4 | % INPUTS: 5 | % - wave: X x Y x T matrix of a real or complex wave pattern 6 | % - Aspace: scalar or X x Y matrix giving spatial amplitude profile 7 | % - Atime: scalar or vector with length T giving temporal amplitude 8 | % profile 9 | 10 | % Apply spatial amplitude 11 | if nargin>1 && ~isempty(Aspace) 12 | if isscalar(Aspace) 13 | wave = Aspace * wave; 14 | elseif ismatrix(Aspace) && size(Aspace,1)==size(wave,1) && ... 15 | size(Aspace,2)==size(wave,2) 16 | wave = bsxfun(@times, Aspace, wave); 17 | else 18 | error('Invalid dimensions of Aspace!') 19 | end 20 | end 21 | 22 | % Apply temporal amplitude 23 | if nargin>2 && ~isempty(Atime) 24 | if isscalar(Atime) 25 | wave = Atime * wave; 26 | elseif isvector(Atime) && length(Atime)==size(wave,3) 27 | Atime = permute(Atime(:), [2, 3, 1]); 28 | wave = bsxfun(@times, Atime, wave); 29 | else 30 | error('Invalid dimensions of Atime!') 31 | end 32 | end 33 | 34 | end 35 | -------------------------------------------------------------------------------- /utils/calc/build_neighbour_matrix.m: -------------------------------------------------------------------------------- 1 | function [neighbour_matrix] = build_neighbour_matrix(locs, nth_ring_matrix) 2 | %% Returns a local patch of surface of the neighbourhood around a vertex. 3 | % 4 | % ARGUMENTS: nth_ring_matrix -- a sparse matrix with nonzero entries if the 5 | % vertices are part of the nth ring neighbourhood. Weight is 1 divided by number of neighbours. 6 | % 7 | % OUTPUT: 8 | % neighbour_matrix -- 9 | % 10 | % REQUIRES: 11 | % 12 | % USAGE: 13 | %{ 14 | 15 | %} 16 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17 | % find vertices/locs that do not have neighbouring triangles, that is they are not part of the triangulation 18 | temp = sum(full(nth_ring_matrix), 2); 19 | neighbour_matrix = nth_ring_matrix; 20 | 21 | % indices of zero entries 22 | zero_idx = find(temp == 0); 23 | neighbours = 6; 24 | neighbour_idx(length(zero_idx), neighbours) = 0; 25 | 26 | for kk=1:length(zero_idx) 27 | this_point = locs(zero_idx(kk), :); 28 | distance_vec = dis(this_point.', locs.'); 29 | [~, idx] = sort(distance_vec); 30 | neighbour_idx(kk, :) = idx(2:neighbours+1); 31 | neighbour_matrix(zero_idx(kk), idx(2:neighbours+1)) = 1/neighbours; 32 | end 33 | 34 | 35 | end % function build_neighbour_matrix() 36 | -------------------------------------------------------------------------------- /utils/calc/dis.m: -------------------------------------------------------------------------------- 1 | %% Calculate Euclidean distance between points. 2 | % not in signal-processing toolbox... 3 | % 4 | % For an arbitrary dimensional space: 5 | % If a is a vector of length the dimension of the space, ie the coordinates of 6 | % a single point, then y is the distance between that point and each of the 7 | % points described by b. 8 | % Otherwise a and b should be the same size, describing two matched sets of 9 | % point pairs, then y is the Euclidean distance between those sets of points. 10 | % 11 | % ARGUMENTS: 12 | % a(Dimension of Space, 1 | Number of Point pairs) -- 1st point|s 13 | % b(Dimension of Space, Number of Point pairs) -- 2nd point|s 14 | % 15 | % OUTPUT: 16 | % y(Number of point pairs, 1) -- Euclidean distance between the 17 | % set of input point pairs 18 | % 19 | % REQUIRES: 20 | % none 21 | % 22 | % USAGE: 23 | %{ 24 | %The distance between one point a and a set of points b in a 2D plane, 25 | a = [2 ; 7]; 26 | b = [6 3 -2; 9 71.5 3.7]; 27 | y = dis(a,b) 28 | %} 29 | %{ 30 | %The distance between two sets of points a and b in a 2D plane, 31 | a = [2 13.2 17 ; 7 27 -2.6]; 32 | b = [6 3 -2 ; 9 71.5 3.7]; 33 | y = dis(a,b) 34 | %} 35 | % MODIFICATION HISTORY: 36 | % MB(2003) -- Original 37 | % SAK(07-08-2006) -- comment. 38 | % SAK(11-08-2008) -- optimised... 39 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 40 | 41 | function y=dis(a,b) 42 | 43 | if size(a)==size(b) 44 | y = sqrt(sum((a-b).^2)); 45 | else 46 | [dim,szt]=size(a); 47 | d=zeros(1,szt); 48 | for i=1:dim 49 | d=d+((a(i,:)-b(i,:)).^2); 50 | end 51 | y=sqrt(d); 52 | end 53 | 54 | end %function -------------------------------------------------------------------------------- /utils/calc/find_boundary_faces.m: -------------------------------------------------------------------------------- 1 | function F = find_boundary_faces(T) 2 | % BOUNDARY_FACES 3 | % F = boundary_faces(T) 4 | % Determine boundary faces of tetrahedra stored in T 5 | % 6 | % Input: 7 | % T tetrahedron index list, m by 4, where m is the number of tetrahedra 8 | % 9 | % Output: 10 | % F list of boundary faces, n by 3, where n is the number of boundary faces 11 | % 12 | 13 | % get all faces 14 | allF = [ ... 15 | T(:,1) T(:,2) T(:,3); ... 16 | T(:,1) T(:,3) T(:,4); ... 17 | T(:,1) T(:,4) T(:,2); ... 18 | T(:,2) T(:,4) T(:,3)]; 19 | % sort rows so that faces are reorder in ascending order of indices 20 | sortedF = sort(allF,2); 21 | % determine uniqueness of faces 22 | [u, m, n] = unique(sortedF,'rows'); 23 | % determine counts for each unique face 24 | counts = accumarray(n(:), 1); 25 | % extract faces that only occurred once 26 | sorted_exteriorF = u(counts == 1,:); 27 | % find in original faces so that ordering of indices is correct 28 | F = allF(ismember(sortedF,sorted_exteriorF,'rows'),:); 29 | 30 | % V are your vertex positions, T are your tet indices 31 | % get boundary faces 32 | F = boundary_faces(T); 33 | % get boundary vertices 34 | b = unique(F(:)); 35 | subplot(1,2,1); 36 | % plot boundary positions 37 | plot3(V(b,1),V(b,2),V(b,3),'.'); 38 | subplot(1,2,2); 39 | % plot just boundary faces 40 | trisurf(F,V(:,1),V(:,2),V(:,3),'FaceAlpha',0.3) 41 | end -------------------------------------------------------------------------------- /utils/calc/find_locs_grid_idx.m: -------------------------------------------------------------------------------- 1 | function [locs_idx_grid, locs_idx_mask] = find_locs_grid_idx(X, Y, Z, locs, in_bdy_mask) 2 | % Description of what this function does 3 | % 4 | % ARGUMENTS: 5 | % xxx -- description here 6 | % 7 | % OUTPUT: 8 | % xxx -- description here 9 | % 10 | % REQUIRES: 11 | % some_function() 12 | % USAGE: 13 | %{ 14 | 15 | 16 | %} 17 | % 18 | % MODIFICATION HISTORY: 19 | % Paula Sanz-Leon -- QIMR October 2019 20 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 21 | 22 | % Find the linear index of the centre's of gravity defined in locs, with 23 | % respect to the grid defined in X, Y, Z 24 | % Returns indices with respect to the full grid and with respect to the 25 | % mask 26 | 27 | % REQUIRES neural-flows/dis() 28 | % is_nan_mask is a mask based on the velcoity compnentns. locsations of 29 | % cogs seem to fall outside the in_bdy_mask 30 | 31 | % Paula QIMR October 2019 32 | 33 | num_points = size(locs, 1); 34 | in_bdy_idx = find(in_bdy_mask); 35 | 36 | S = [X(in_bdy_idx) Y(in_bdy_idx) Z(in_bdy_idx)].'; 37 | locs_idx_grid(num_points, 1) = 0; 38 | locs_idx_mask(num_points, 1) = 0; 39 | 40 | for kk = 1:num_points 41 | this_point = round(locs(kk, :).'); 42 | d = dis(this_point, S); 43 | [~, idx] = min(d); 44 | locs_idx_grid(kk) = in_bdy_idx(idx); 45 | locs_idx_mask(kk) = idx; 46 | end 47 | 48 | end % find_locs_grid_idx() 49 | 50 | -------------------------------------------------------------------------------- /utils/calc/get_convex_hull.m: -------------------------------------------------------------------------------- 1 | function get_convex_hull(obj_data, alpha_radius, hemi1_idx, hemi2_idx) 2 | %% Returns a local patch of surface of the neighbourhood around a vertex. 3 | % 4 | % ARGUMENTS: params -- almighty structure 5 | % obj_data -- handle to matfile with original unstructured data 6 | % left_idx -- indices of nodes on the left hemisphere 7 | % right_idx -- indices of nodes on the right hemisphere 8 | % 9 | % OUTPUT: 10 | % None, saves automagically to obj_data 11 | % 12 | % REQUIRES: 13 | % 14 | % USAGE: 15 | %{ 16 | 17 | %} 18 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 19 | % Calculate the convex hull of scattered points for each hemisphere separately and both 20 | 21 | % Calculate individual convex hulls 22 | 23 | 24 | num_nodes_hemi1 = length(hemi1_idx); 25 | 26 | if ~isempty(hemi2_idx) 27 | tri_hemi1 = get_boundary_triangles(obj_data.locs(hemi1_idx, :), alpha_radius); 28 | tri_hemi2 = get_boundary_triangles(obj_data.locs(hemi2_idx, :), alpha_radius); 29 | tri_hemi2 = tri_hemi2 + num_nodes_hemi1; % fix numbering of vertex indices, assumes all the left nodes are contiguous 30 | tri_both = get_boundary_triangles(obj_data.locs, alpha_radius); 31 | 32 | masks.innies_triangles_bi = tri_both; 33 | masks.innies_triangles_lr = [tri_hemi1; tri_hemi2]; 34 | else 35 | tri_hemi1 = get_boundary_triangles(obj_data.locs(hemi1_idx, :), alpha_radius); 36 | masks.innies_triangles_bi = tri_hemi1; 37 | masks.innies_triangles_lr = tri_hemi1; 38 | end 39 | obj_data.masks = masks; 40 | 41 | end % get_boundary_masks() 42 | 43 | function tri_list = get_boundary_triangles(locs, alpha_radius) 44 | shp = alphaShape(locs, alpha_radius); 45 | % The boundary of the centroids is an approximation of the cortex 46 | tri_list = shp.boundaryFacets; 47 | end -------------------------------------------------------------------------------- /utils/calc/get_grid_limits.m: -------------------------------------------------------------------------------- 1 | function [min_x, min_y, min_z, max_x, max_y, max_z, int_locs] = get_grid_limits(points_xyz, hx, hy, hz, lim_type) 2 | % basic function that I've been using again and again 3 | % TODO - document etc 4 | if nargin < 5 5 | lim_type = 'ceil'; 6 | end 7 | 8 | % Human-readable labels for indexing dimensions of 3D arrays 9 | x_dim = 1; 10 | y_dim = 2; 11 | z_dim = 3; 12 | 13 | if strcmp(lim_type, 'ceil') 14 | % Round up to the nearest integer, using ceil avoids errors in the interpolated data. 15 | int_locs = ceil(abs(points_xyz)).*sign(points_xyz); 16 | border_factor = 2; 17 | else 18 | int_locs = points_xyz; 19 | border_factor = 3; 20 | end 21 | 22 | % Minima 23 | min_x = min(int_locs(:, x_dim)) - border_factor*hx; 24 | min_y = min(int_locs(:, y_dim)) - border_factor*hy; 25 | min_z = min(int_locs(:, z_dim)) - border_factor*hz; 26 | 27 | % Maxima 28 | max_x = max(int_locs(:, x_dim)) + border_factor*hx; 29 | max_y = max(int_locs(:, y_dim)) + border_factor*hy; 30 | max_z = max(int_locs(:, z_dim)) + border_factor*hz; 31 | 32 | end % get_get_grid_boundaries() -------------------------------------------------------------------------------- /utils/calc/get_laplacian_kernel_3d.m: -------------------------------------------------------------------------------- 1 | function [Gx, Gy, Gz] = get_laplacian_kernel_3d() 2 | % Returns the 3D normalized Laplacian kernel of size [3, 3, 3] 3 | Gx = zeros(3,3,3); 4 | Gy = Gx; 5 | Gz = Gx; 6 | 7 | Gx(:,:,1) = [-1 0 1; -2 0 2; -1 0 1]; 8 | Gx(:,:,2) = [-1 0 1; -2 0 2; -1 0 1]; 9 | Gx(:,:,3) = [-1 0 1; -2 0 2; -1 0 1]; 10 | Gx = Gx./sum(abs(Gx(:))); 11 | 12 | Gy(:,:,1) = Gx(:, :, 1)'; 13 | Gy(:,:,2) = Gx(:, :, 2)'; 14 | Gy(:,:,3) = Gx(:, :, 3)'; 15 | 16 | Gz(:,:,1) = [-1 -2 -1; -1 -2 -1; -1 -2 -1]; 17 | Gz(:,:,2) = [ 0 0 0; 0 0 0; 0 0 0]; 18 | Gz(:,:,3) = [ 1 2 1; 1 2 1; 1 2 1]; 19 | Gz = Gz./sum(abs(Gz(:))); 20 | 21 | end % function get_laplacian_kernel_3d() 22 | -------------------------------------------------------------------------------- /utils/calc/get_nth_ring_matrix.m: -------------------------------------------------------------------------------- 1 | function [nth_ring_matrix] = get_nth_ring_matrix(tr, focus_vertex_idx_list, nth_ring) 2 | %% Returns a local patch of surface of the neighbourhood around a vertex. 3 | % 4 | % ARGUMENTS: 5 | % tr -- a Matlab's triangulation object with the original/complete lobal surface 6 | % focus_vertex_idx_list -- a 1D array (column vector) of size (n x 1) with the indices of the vertices for which we will extract the nth ring 7 | % nth_ring -- an integer describing how many rings around the focal vertices we need. 8 | % 9 | % OUTPUT: 10 | % nth_ring_matrix -- a sparse matrix with nonzero entries if the 11 | % vertices are part of the nth ring neighbourhood. Weight is 1 divided by number of neighbours. 12 | % REQUIRES: 13 | % Matlab's triangulation and get_nth_ring() 14 | % 15 | % USAGE: 16 | %{ 17 | load('CortexBdy_alpha-30_513parc.mat', 'Vertices', 'Triangles'); 18 | tr = triangulation(Triangles, Vertices); % Convert to triangulation object 19 | focus_vx_idx_list = [1:513].'; 20 | nth_ring = 1; 21 | [nth_ring_matrix] = get_nth_ring_matrix(tr, focus_vx_idx_list, nth_ring); 22 | %} 23 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 24 | 25 | 26 | if nargin <3 27 | nth_ring = 1; 28 | end 29 | 30 | num_vertices = size(focus_vertex_idx_list, 1); 31 | nth_ring_matrix = sparse(num_vertices, num_vertices); 32 | 33 | for vv = 1:num_vertices 34 | [~, ~, global_vx_indices, ~, nth_ring_size] = get_nth_ring(tr, focus_vertex_idx_list(vv), nth_ring); 35 | nth_ring_matrix(vv, global_vx_indices(2:end)) = 1/max(nth_ring_size); 36 | end 37 | 38 | 39 | end % function get_nth_ring_matrix() 40 | -------------------------------------------------------------------------------- /utils/calc/get_seeding_locations.m: -------------------------------------------------------------------------------- 1 | function seed_locs = get_seeding_locations(locs, modality, seed) 2 | 3 | if nargin < 3 4 | seed = 2020; 5 | end 6 | 7 | switch modality 8 | case {"nodes", "regions", "nodal"} 9 | seed_locs = locs; 10 | % do something 11 | case {"random-dense", "random_dense"} 12 | % seeds 2*num nodes streamlines 13 | rng(seed) 14 | node_idx1 = randi([1, size(locs, 1)], size(locs, 1), 1); 15 | node_idx2 = randi([1, size(locs, 1)], size(locs, 1), 1); 16 | seed_locs = (locs(node_idx1, :) + locs(node_idx2, :))/2; 17 | seed_locs = vertcat(seed_locs, locs); 18 | case {"random-sparse", "random_sparse"} 19 | % seeds 0.5*num nodes streamlines 20 | rng(seed) 21 | node_idx1 = randi([1, size(locs, 1)], round(size(locs, 1)/2), 1); 22 | node_idx2 = randi([1, size(locs, 1)], round(size(locs, 1)/2), 1); 23 | seed_locs = (locs(node_idx1, :) + locs(node_idx2, :))/2; 24 | seed_locs = vertcat(seed_locs, locs); 25 | otherwise 26 | error(['neural-flows:' mfilename ':UnknownCase: Requested unknown seeding case for data on an unstructured grid. Options: {"nodes", "random-sparse", "random-dense"}']); 27 | end 28 | end % function get_seeding_locations() -------------------------------------------------------------------------------- /utils/calc/get_seeding_locations_2d_slice.m: -------------------------------------------------------------------------------- 1 | function [seeding_locs] = get_seeing_locations_2d_slice(X0, Y0, modality, seed) 2 | 3 | if nargin < 4 4 | seed = 2020; 5 | end 6 | 7 | rng(seed) 8 | 9 | switch modality 10 | case {'grid', 'gridded'} 11 | seeding_locs.X = X0(:); 12 | seeding_locs.Y = Y0(:); 13 | case {'random_sparse', 'random-sparse'} 14 | seeding_locs.X = min(X0(:)) + (max(X0(:)) - min(X0(:))) * rand(floor(size(X0)./2)); 15 | seeding_locs.Y = min(Y0(:)) + (max(Y0(:)) - min(Y0(:))) * rand(floor(size(Y0)./2)); 16 | case {'random_dense', 'random-dense'} 17 | seeding_locs.X = min(X0(:)) + (max(X0(:)) - min(X0(:))) * rand(size(X0)); 18 | seeding_locs.Y = min(Y0(:)) + (max(Y0(:)) - min(Y0(:))) * rand(size(Y0)); 19 | otherwise 20 | error(['neural-flows::' mfilename '::UnknownCase'], ... 21 | 'Unknown modality for seeding streamlines on a 2D structured grid.'); 22 | 23 | end 24 | 25 | end % function get_seeding_locations_2d_slice() 26 | -------------------------------------------------------------------------------- /utils/calc/get_seeding_locations_3d_slice.m: -------------------------------------------------------------------------------- 1 | function [seeding_locs] = get_seeding_locations_3d_slice(X0, Y0, Z0, modality, seed) 2 | 3 | if nargin < 5 4 | seed = 2020; 5 | end 6 | 7 | rng(seed) 8 | 9 | switch modality 10 | case {'grid', 'gridded'} 11 | num_points = size(X0, 1); 12 | locs_idx = 1:num_points; 13 | case {'random_sparse', 'random-sparse'} 14 | num_points = 256; % Hardcode, otherwise it gets ugly 15 | locs_idx = randi([1 length(X0(:))], num_points, 1); 16 | case {'random_dense', 'random-dense'} 17 | num_points = 1024; % Hardocde, othwerwise it gets ugly 18 | locs_idx = randi([1 length(X0(:))], num_points, 1); 19 | otherwise 20 | error(['neural-flows::' mfilename '::UnknownCase'], ... 21 | 'Unknown modality for seeding streamlines on a structured 3D grid.'); 22 | end 23 | seeding_locs.X = X0(locs_idx); 24 | seeding_locs.Y = Y0(locs_idx); 25 | seeding_locs.Z = Z0(locs_idx); 26 | 27 | end % function get_seeding_locations_3d_slice() -------------------------------------------------------------------------------- /utils/calc/get_structured_grid.m: -------------------------------------------------------------------------------- 1 | function [X, Y, Z, grid_size] = get_structured_grid(points_xyz, hx, hy, hz, lim_type) 2 | % This function sgenreates a structured grid using meshgrid, from a 3 | % collection of scatterd points/locationss in 3D space. 4 | % 5 | % ARGUMENTS: 6 | % points_xyz -- a 2D array of size [num_regions/nodes/locations x 3] 7 | % 8 | % hx -- a scalar, desired space step size of the regular grid along x 9 | % hy -- a scalar, desired space step size of the regular grid along y 10 | % hz -- a scalar, desired space step size of the regular grid along z 11 | % 12 | % OUTPUTS: 13 | % X, Y, Z -- 3D arrays of size [M, N, P] generated using meshgrid. 14 | % grid_size -- vector with the size of the grid (ie [M, N, P]) 15 | % 16 | % REQUIRES: 17 | % get_grid_limits() 18 | % 19 | % USAGE: 20 | %{ 21 | 22 | %} 23 | % 24 | % MODIFICATION HISTORY: 25 | % Paula Sanz-Leon, QIMR Berghofer February 2019 26 | 27 | 28 | if nargin < 5 29 | % round limits to the next integer 30 | lim_type = 'ceil'; 31 | end 32 | 33 | 34 | [min_x, min_y, min_z, max_x, max_y, max_z, ~] = get_grid_limits(points_xyz, hx, hy, hz, lim_type); 35 | 36 | 37 | % Create the grid -- THIS IS THE PROBLEM WITH SPACING 38 | xx = min_x:hx:max_x; 39 | yy = min_y:hy:max_y; 40 | zz = min_z:hz:max_z; 41 | 42 | [X, Y, Z] = meshgrid(xx, yy, zz); 43 | grid_size = size(X); 44 | 45 | end % function get_structured_grid() 46 | -------------------------------------------------------------------------------- /utils/calc/get_triangle_barycenter.m: -------------------------------------------------------------------------------- 1 | function [barycenter] = get_triangle_barycenter(vx0, vx1, vx2) 2 | % Calculates the barycenter of a triangle, given the vertex coordinates 3 | % ARGUMENTS: 4 | % vx0 -- coordinate of first vertex. A vector of [1 x 3] or [3 x 1] 5 | % vx1 -- coordinate of second vertex. A vector of [1 x 3] or [3 x 1] 6 | % vx2 -- coordinate of third vertex. A vector of [1 x 3] or [3 x 1] 7 | % 8 | % OUTPUT: 9 | % barycenter -- the coordinates of the barycentre 10 | % 11 | % REQUIRES: 12 | % None 13 | % 14 | % AUTHOR: 15 | % Paula Sanz-Leon (2019-02-09). 16 | % 17 | % USAGE: 18 | %{ 19 | 20 | %} 21 | % 22 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 23 | Pa = vx0(:); 24 | Pb = vx1(:); 25 | Pc = vx2(:); 26 | 27 | L1 = (Pb + Pc)/2 -Pa; 28 | L2 = (Pa + Pc)/2 -Pb; % directrices 29 | P21 = Pb - Pa; 30 | P1 = Pa; 31 | 32 | ML = [L1 -L2]; % Coefficient Matrix 33 | lambda = ML\P21; % Solving the linear system 34 | barycenter = P1 + lambda(1)*L1; % Line Equation evaluated at lambda(1) 35 | 36 | % end function get_triangle_barycenter() 37 | -------------------------------------------------------------------------------- /utils/calc/guesstimate_nullflows_threshold.m: -------------------------------------------------------------------------------- 1 | function [detection_threshold] = flows3d_hs3d_detect_nullflows_guesstimate_threshold(data) 2 | % Ad hoc way of guesstimating threshold for detecting singularities. 3 | 4 | %[~, edges] = histcounts(data); 5 | 6 | % discard first edge 7 | % data assumed to be a sequence in time of the minimum values of the vector field norm 8 | detection_threshold = [0; median(data)]; 9 | 10 | end % function guesstimate_detection_theshold() 11 | -------------------------------------------------------------------------------- /utils/calc/kinetic_energy.m: -------------------------------------------------------------------------------- 1 | function ke = kinetic_energy(v, varargin) 2 | 3 | if nargin < 2 4 | m = 1.0; % mass is 1 5 | end 6 | % E = (1/2)*m*v^2 7 | ke = 0.5.*m.*v.^2; 8 | end % function kinetic_energy() -------------------------------------------------------------------------------- /utils/calc/normalise_vector_field.m: -------------------------------------------------------------------------------- 1 | function [v, norm_vf] = normalise_vector_field(v, dim) 2 | %% Normalises the input vector field using the L2 norm 3 | % 4 | % ARGUMENTS: 5 | % v -- a 2D array of size [M, dim]; 6 | % dim -- dimension of the embedding space (2 or 3) 7 | % OUTPUT: 8 | % v -- nD array of size [M, dim] whose vectors have unit 9 | % norm. 10 | % norm_vf -- an array of size [M, 1] with the norm of the 11 | % original vector field. 12 | % AUTHOR: 13 | % Paula Sanz-Leon, QIMR Berghofer 2019-01 14 | % USAGE: 15 | %{ 16 | 17 | %} 18 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 19 | norm_vf = sqrt(sum(v.^2, 2)); 20 | 21 | try 22 | % Avoid division by zero 23 | norm_vf(norm_vf < 1e-8) = 1; 24 | v = v./norm_vf; 25 | catch 26 | norm_vf(norm_vf < 1e-8) = 1; 27 | disp('Cannot perform implicit expansion/broadcasting of arrays. Using repmat instead ...') 28 | v = v .* repmat(1./norm_vf, [ones(dim-1,1)' size(v, dim)]); 29 | end 30 | 31 | end % function normalise_vector_field() 32 | -------------------------------------------------------------------------------- /utils/calc/s3d_str2num_label.m: -------------------------------------------------------------------------------- 1 | function [singularity_classification_num_list] = singularity3d_convert_str2num_label(singularity_classification_str_list) 2 | % This function maps singularity human-readable string labels inside the 3 | % cell array into integer numbers for quantitative classification, 4 | % 5 | % ARGUMENTS: 6 | % singularity_classification_str_list -- a celll array of size 1 x 7 | % tpts, where each element is a cell array of different size 8 | % depending on how many singularities where found. 9 | % 10 | % OUTPUT: 11 | % singularity_classification_num_list -- a cell array of the same 12 | % size as singularity_classification_str_list, but with numeric 13 | % labels. 14 | % 15 | % REQUIRES: 16 | % s3d_get_num_label() 17 | % USAGE: 18 | %{ 19 | 20 | %} 21 | % AUTHOR: Paula Sanz-Leon, QIMR February 2019 22 | 23 | tpts = size(singularity_classification_str_list, 2); 24 | singularity_classification_num_list = cell(size(singularity_classification_str_list)); 25 | 26 | for tt=1:tpts 27 | singularity_classification_num_list{tt} = cellfun(@(x) s3d_get_numlabel(x), singularity_classification_str_list{tt}); 28 | end 29 | 30 | end 31 | % function s3d_str2num_label() 32 | -------------------------------------------------------------------------------- /utils/calc/switch_index_mode.m: -------------------------------------------------------------------------------- 1 | function xyz_idx = switch_index_mode(xyz_lidx, index_mode, grid_size) 2 | % A dummy function that wraps Matlab's ind2sub 3 | 4 | switch index_mode 5 | case 'linear' 6 | xyz_idx = xyz_lidx; 7 | case 'subscript' % Note: I vaguely remember this part not working properly. 8 | [x_idx, y_idx, z_idx] = ind2sub(grid_size, xyz_lidx); 9 | xyz_idx = [x_idx, y_idx, z_idx]; 10 | end 11 | end % function switch_index_mode() 12 | -------------------------------------------------------------------------------- /utils/misc/display_info_banner.m: -------------------------------------------------------------------------------- 1 | function display_info_banner(mfilename_fun, core_stage_name, core_stage_colour, stage) 2 | 3 | cprintf(core_stage_colour, '\n------------------------------------------------------------------------\n') 4 | cprintf('#18181b', '%s', strcat('neural-flows:: ', mfilename_fun, '::Info:: ')) 5 | cprintf(core_stage_colour, core_stage_name) 6 | if stage 7 | cprintf('#18181b', ' STAGE.\n') 8 | else 9 | cprintf('#18181b', '\n') 10 | end 11 | cprintf(core_stage_colour, '------------------------------------------------------------------------\n') 12 | 13 | 14 | end % display_info_banner() -------------------------------------------------------------------------------- /utils/misc/display_toolbox_name.m: -------------------------------------------------------------------------------- 1 | function display_toolbox_name() 2 | cprintf('#18181b', '%s\n', strcat(' .__ _____.__ ')) 3 | cprintf('#18181b', '%s\n', strcat(' ____ ____ __ ______________ | | _/ ____\ | ______ _ ________')) 4 | cprintf('#18181b', '%s\n', strcat(' / \_/ __ \| | \_ __ \__ \ | | \ __\| | / _ \ \/ \/ / ___/')) 5 | cprintf('#18181b', '%s\n', strcat('| | \ ___/| | /| | \// __ \| |__ | | | |_( <_> ) /\___ \ ')) 6 | cprintf('#18181b', '%s\n', strcat('|___| /\___ >____/ |__| (____ /____/ |__| |____/\____/ \/\_//____ >')) 7 | cprintf('#18181b', '%s\n', strcat(' \/ \/ \/ \/ ')) 8 | 9 | end % display_toolbox_name() -------------------------------------------------------------------------------- /utils/misc/s3d_get_base_singularity_list.m: -------------------------------------------------------------------------------- 1 | function singularity_list = s3d_get_base_singularity_list() 2 | % This is kind of a dummy function that returns the list with available 3 | % types of singularities in the classification functions. 4 | % 5 | % 6 | % ARGUMENTS: 7 | % None 8 | % 9 | % 10 | % OUTPUT: 11 | % singularity_list -- a cell array with human readbale string, with 12 | % the names of 3D hyperbolic singularities. 13 | % 14 | % REQUIRES: 15 | % None 16 | % USAGE: 17 | %{ 18 | 19 | %} 20 | % 21 | % NOTE TO SELF: Check this list is consitent with s3d_get_numlabel() 22 | 23 | singularity_list = {'source', ... 24 | 'sink', ... 25 | 'spiral-source',... 26 | 'spiral-sink',... 27 | '1-2-saddle',... 28 | '2-1-saddle',... 29 | '1-2-spiral-saddle', ... 30 | '2-1-spiral-saddle', ... 31 | 'source-po',... % untested 32 | 'sink-po',... % untested 33 | 'saddle-po',... % untested 34 | 'twisted-po',... % untested 35 | 'spiral-source-po',... % untested 36 | 'spiral-sink-po', ... % untested 37 | '1-1-0-saddle', ... % untested 38 | 'nan', ... 39 | 'boundary', ... 40 | 'empty'}; 41 | 42 | end % function s3d_get_base_singularity_list() 43 | -------------------------------------------------------------------------------- /utils/misc/tik.m: -------------------------------------------------------------------------------- 1 | function tstart = tik(varargin) 2 | %% Prints string with the current date time - does not actually time execution of programs 3 | % 4 | % ARGUMENTS: 5 | % None 6 | % 7 | % OUTPUT: 8 | % tstart -- a datetime string 9 | % 10 | % AUTHOR: 11 | % Paula Sanz-Leon, QIMR Berghofer December 2019 12 | % USAGE: 13 | %{ 14 | tstart = tik() 15 | tok(tsart) 16 | 17 | %} 18 | % TODO: generalise so as input argument we pass a number of \n and or \t, 19 | % that is a sequence of string formatters. 20 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 21 | tstart = string(datetime('now')); 22 | if nargin < 1 23 | fprintf('\n%s%s\n', ['Started : ' tstart]); 24 | else 25 | fprintf('\n\t%s%s\n', ['Started : ' tstart]); 26 | end 27 | end % function tik() 28 | -------------------------------------------------------------------------------- /utils/misc/tok.m: -------------------------------------------------------------------------------- 1 | function varargout = tok(tstart, time_unit, varargin) 2 | %% Gets currrent datetime, calculates and prints elapsed time based on the input datetime string `tsart` 3 | % 4 | % ARGUMENTS: 5 | % tsart -- a string generated with function tik() 6 | % 7 | % OUTPUT: 8 | % Prints to screen 9 | % 10 | % AUTHOR: 11 | % Paula Sanz-Leon, QIMR Berghofer December 2019 12 | % USAGE: 13 | %{ 14 | tstart = tik() 15 | tok(tsart) 16 | 17 | %} 18 | % TODO: generalise so as input argument we pass a number of \n and or \t, 19 | % that is a sequence of string formatters. 20 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 21 | 22 | tend = string(datetime('now')); 23 | 24 | 25 | if nargin < 2 26 | time_unit = 'seconds'; 27 | divisor = 1; 28 | end 29 | 30 | tik_tok = etime(datevec(tend), datevec(tstart)); 31 | 32 | switch time_unit 33 | case {'seconds', 'sec', 's'} 34 | divisor = 1; 35 | case {'minutes', 'min', 'mins', 'm'} 36 | divisor = 60; 37 | case {'hours', 'hour', 'h', 'hr', 'hrs'} 38 | divisor = 3600; 39 | otherwise 40 | error(['neural-flows:' mfilename ':UnknownUnits'], 'Unknown time units. Options: {"seconds", "minutes", "hours"}'); 41 | 42 | end % switch case block 43 | 44 | if nargin < 3 45 | fprintf('%s%s\n', ['Finished: ' tend]) 46 | fprintf('%s%s%s%s\n', ['Elapsed : ' string(tik_tok/divisor) ' ' time_unit]); 47 | else 48 | fprintf('\t%s%s\n', ['Finished: ' tend]) 49 | fprintf('\t%s%s%s%s\n', ['Elapsed : ' string(tik_tok/divisor) ' ' time_unit]); 50 | end 51 | 52 | if nargout > 0 53 | varargout{1} = tik_tok; 54 | end 55 | end % function tok() 56 | -------------------------------------------------------------------------------- /utils/signal/bandpass_filter.m: -------------------------------------------------------------------------------- 1 | %% Basic functionality to bandapass-filter data, a wrapper of butteworth filters 2 | % 3 | % ARGUMENTS: 4 | % data -- a 2D array of size [time x nodes/locs/channels/vertices] with activity. 5 | % flo -- a float with the low-frequency cutoff in Hz. 6 | % fhi -- a float with the high-frequency cutoff in Hz. 7 | % filter_order -- an integere with the filter order. 8 | % fs -- a float with the sampling frequency of data, in Hz. 9 | % 10 | % OUTPUT: 11 | % datafiltered -- a 2D array of size [time x nodes/locs/channels/vertices] 12 | % with the frequencies in the range [flow fhi]. 13 | % 14 | % REQUIRES: 15 | % 16 | % USAGE: 17 | %{ 18 | 19 | %} 20 | % 21 | % MODIFICATION HISTORY: 22 | % Paula Sanz-Leon, QIMR Berghofer 2019 23 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 24 | 25 | function [datafiltered] = bandpass_filter(data, flo, fhi, filter_order, fs) 26 | 27 | % Build Butterworth filter 28 | cutoff_freqs = [flo fhi]; 29 | % Normalised frequency 30 | wn = cutoff_freqs / (fs/2); 31 | [b, a] = butter(filter_order, wn); 32 | % Filter data 33 | datafiltered = filtfilt(b, a, data); 34 | end % function bandpass_filter() 35 | -------------------------------------------------------------------------------- /utils/vis/add_vertices.m: -------------------------------------------------------------------------------- 1 | function x = add_vertices(x, max_length) 2 | % dummy function that adds vertices to the streamlines, so they are all of 3 | % the same length -- necessary to use streamparticles 4 | this_length = size(x, 1); 5 | last_values = x(end, :); 6 | 7 | x(this_length:max_length, :) = last_values(ones((max_length-this_length)+1, 1), :); 8 | 9 | end -------------------------------------------------------------------------------- /utils/vis/colourmaps/greenyellowred.m: -------------------------------------------------------------------------------- 1 | %% Return a colormap array [m,3] -- diverging data or sequential data, like 2 | % a traffic light. 3 | % ARGUMENTS: 4 | % m -- number of colours in colormap. 5 | % ordering -- ['fwd'|'rev'] ordering of returned colormap array. 6 | % 7 | % OUTPUT: 8 | % c -- [m,3] colormap array. 9 | % 10 | % REQUIRES: 11 | % 12 | % AUTHOR: 13 | % Paula Sanz-Leon (2019-06-18). 14 | % 15 | % USAGE: 16 | %{ 17 | 18 | %} 19 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 20 | 21 | function [c] = greenyellowred(m, ordering) 22 | %% If number of colours (m) not specified, try setting from current colormap. 23 | if nargin < 1 || isempty(m) 24 | f = get(groot, 'CurrentFigure'); 25 | if isempty(f) 26 | m = size(get(groot, 'DefaultFigureColormap'), 1); 27 | else 28 | m = size(f.Colormap, 1); 29 | end 30 | end 31 | 32 | if nargin < 2 || isempty(ordering) 33 | ordering = 'fwd'; 34 | end 35 | 36 | %% Basis colormap from http://colorbrewer2.org 37 | bcm = [165,0,38; ... 38 | 215,48,39; ... 39 | 244,109,67; ... 40 | 253,174,97; ... 41 | 254,224,139; ... 42 | 255,255,191; ... 43 | 217,239,139; ... 44 | 166,217,106; ... 45 | 102,189,99; ... 46 | 26,152,80; ... 47 | 0,104,55] ./ 255.0; 48 | bcm = flipud(bcm); 49 | 50 | %% Number of colours in basis colormap. 51 | nc = size(bcm, 1); 52 | 53 | %% Colour step size to produce m colours for output. 54 | cstep = (nc - 1) / (m - 1); 55 | 56 | %% Linear interpolation of basis colormap. 57 | c = interp1(1:nc, bcm, 1:cstep:nc); 58 | 59 | if strcmp(ordering, 'rev') % reverse colormap 60 | c = c(end:-1:1, :); 61 | end 62 | 63 | end % function greenyellowred() 64 | -------------------------------------------------------------------------------- /utils/vis/colourmaps/redyellowblue.m: -------------------------------------------------------------------------------- 1 | %% Return a colormap array [m,3] -- diverging, shades of red-yellow-blue. 2 | % Colourblind friendly 3 | % 4 | % 5 | % ARGUMENTS: 6 | % m -- number of colours in colormap. 7 | % ordering -- ['fwd'|'rev'] ordering of returned colormap array. 8 | % 9 | % OUTPUT: 10 | % c -- [m,3] colormap array. 11 | % AUTHOR: 12 | % Paula Sanz-Leon (2018-12-21). 13 | % 14 | % USAGE: 15 | %{ 16 | cmap = redyellowblue(64); 17 | %} 18 | % 19 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 20 | 21 | 22 | function [c] = redyellowblue(m, ordering) 23 | %% If number of colours (m) not specified, try setting from current colormap. 24 | if nargin < 1 25 | f = get(groot, 'CurrentFigure'); 26 | if isempty(f) 27 | m = size(get(groot, 'DefaultFigureColormap'), 1); 28 | else 29 | m = size(f.Colormap, 1); 30 | end 31 | end 32 | 33 | if nargin < 2 34 | ordering='fwd'; 35 | end 36 | 37 | bcm =[165,0,38;... 38 | 215,48,39;... 39 | 244,109,67;... 40 | 253,174,97;... 41 | 254,224,144;... 42 | 255,255,191;... 43 | 224,243,248;... 44 | 171,217,233;... 45 | 116,173,209;... 46 | 69,117,180;... 47 | 49,54,149]./255; 48 | 49 | %% Number of colours in basis colormap. 50 | nc = size(bcm, 1); 51 | 52 | %% Colour step size to produce m colours for output. 53 | cstep = (nc - 1) / (m - 1); 54 | 55 | %% Linear interpolation of basis colormap. 56 | c = interp1(1:nc, bcm, 1:cstep:nc); 57 | 58 | if strcmp(ordering, 'rev') % reverse colormap 59 | c = c(end:-1:1, :); 60 | end 61 | end % function redyellowwhiteblue() 62 | -------------------------------------------------------------------------------- /utils/vis/find_min_max.m: -------------------------------------------------------------------------------- 1 | function [min_d, max_d] = find_min_max(data, minmax_mode) 2 | %% Finds minimum and maximum across all elements of input array data 3 | % 4 | % ARGUMENTS: 5 | % data -- an nD array with numeical values (int, float, etc) 6 | % minmax_mode -- an string specifying what type of min max values the 7 | % function returns. The mode 'symmetric' is the only vailable 8 | % alternative now. This mode is useful for diverging data around zero. 9 | % The min max values returned are useful for setting 10 | % caxis in image-based figures. 11 | % 12 | % OUTPUT: 13 | % min_d -- scalar. Minimum value of data. 14 | % max_d -- scalar. Maximum value of data. 15 | % 16 | % REQUIRES: 17 | % none 18 | % 19 | % USAGE: 20 | %{ 21 | 22 | %} 23 | % 24 | % AUTHOR: 25 | % Paula Sanz-Leon, QIMR Berghofer, 2019 26 | % TODO: use switch case block once there are more minma_mode options 27 | if nargin < 2 28 | minmax_mode = 'none'; 29 | end 30 | 31 | if strcmp(minmax_mode, 'symmetric') 32 | % Useful for diverging data around zero 33 | max_d = max(abs(data(:))); 34 | min_d = -max_d; 35 | else 36 | min_d = min(data(:)); 37 | max_d = max(data(:)); 38 | end 39 | 40 | 41 | end % function fin_min_max() -------------------------------------------------------------------------------- /utils/vis/get_number_subplots.m: -------------------------------------------------------------------------------- 1 | function [p, n] = get_number_subplots(n) 2 | % function [p, n] = get_number_subplots(n) 3 | % 4 | % Purpose 5 | % Calculate how many rows and columns of sub-plots are needed to 6 | % neatly display n subplots. 7 | % 8 | % Inputs 9 | % n - the number of subplots we need 10 | % 11 | % Outputs 12 | % p - a vector length 2 defining the number of rows and number of 13 | % columns required to show n plots. 14 | % [ n - the current number of subplots. This output is used only by 15 | % this function for a recursive call.] 16 | % 17 | % 18 | % 19 | % Example: neatly lay out 13 sub-plots 20 | % >> p=numSubplots(13) 21 | % p = 22 | % 3 5 23 | % for i=1:13; subplot(p(1),p(2),i), pcolor(rand(10)), end 24 | % 25 | % 26 | % Rob Campbell - January 2010 27 | 28 | 29 | while isprime(n) & n >4 30 | n=n+1; 31 | end 32 | 33 | p = factor(n); 34 | 35 | if length(p)==1 36 | p=[1,p]; 37 | return 38 | end 39 | 40 | 41 | while length(p)>2 42 | if length(p)>=4 43 | p(1)=p(1)*p(end-1); 44 | p(2)=p(2)*p(end); 45 | p(end-1:end)=[]; 46 | else 47 | p(1)=p(1)*p(2); 48 | p(2)=[]; 49 | end 50 | p=sort(p); 51 | end 52 | 53 | %Reformat if the column/row ratio is too large: we want a roughly 54 | %square design 55 | while p(2)/p(1)>2.5 56 | N=n+1; 57 | [p,n]=get_number_subplots(N); %Recursive! 58 | end 59 | end % function get_number_subplots() 60 | 61 | -------------------------------------------------------------------------------- /utils/vis/get_quantile_crange.m: -------------------------------------------------------------------------------- 1 | function crange = get_quantile_crange(data) 2 | % This trick is used throughout plotting functions to get a decent colour 3 | % range. 4 | % 5 | % 6 | % ARGUMENTS: 7 | % data -- generally a ND array with timeseries of some sort. 8 | % 9 | % OUTPUT: 10 | % crange -- a [2 x 1] vector with data limits, to be used as colour limits 11 | % 12 | % REQUIRES: 13 | % None 14 | % 15 | % AUTHOR: 16 | % James A. Roberts, QIMR 17 | % USAGE: 18 | %{ 19 | 20 | %} 21 | % 22 | 23 | %NOTE: use quantiles because MOST points lie in a relatively fixed range, 24 | % and min and max values can be way outside. 25 | if length(data)>10000 % downsampling here for speed. 26 | crange=quantile(data(1:100:end),[0.001 0.999]); 27 | else 28 | crange=quantile(data(1:end),[0.001 0.999]); 29 | end 30 | 31 | end % get_quantile_crange() 32 | -------------------------------------------------------------------------------- /utils/vis/get_set_options.m: -------------------------------------------------------------------------------- 1 | function [v, varargout] = get_set_options(options, fieldname, v) 2 | % getoptions - gets a value of options.fieldname value 3 | % 4 | % v = get_set_options(options, 'thisfield', v0); 5 | % is equivalent to: 6 | % if isfield(options, 'thisfield') % get 7 | % v = options.thisfield; 8 | % else 9 | % v = v0; 10 | % options.thisfield=v0; % set 11 | % end 12 | % 13 | % Paula QIMR 2019 14 | % NOTE: probably better to have get and a set functions separately 15 | 16 | if nargin < 3 17 | error('Not enough arguments.'); 18 | end 19 | 20 | if isfield(options, fieldname) 21 | v = eval(['options.' fieldname ';']); 22 | return 23 | end 24 | 25 | % If the field did not exist before, the function creates it and assigns 26 | % the value passed as input argument. 27 | eval(['options.' fieldname ' = v;']); 28 | varargout{1} = options; 29 | end % function get_set_options() -------------------------------------------------------------------------------- /utils/vis/hex2rgb.m: -------------------------------------------------------------------------------- 1 | function rgb = hex2rgb(hexString) 2 | if size(hexString,2) ~= 6 3 | error('invalid input: not 6 characters'); 4 | else 5 | r = double(hex2dec(hexString(1:2)))/255; 6 | g = double(hex2dec(hexString(3:4)))/255; 7 | b = double(hex2dec(hexString(5:6)))/255; 8 | rgb = [r, g, b]; 9 | end 10 | end -------------------------------------------------------------------------------- /utils/vis/interpolated_colourmap.m: -------------------------------------------------------------------------------- 1 | function cmap = interpolated_colourmap(colour_a, colour_b, colour_c, num_colours) 2 | 3 | cmap(1, :) = colour_a; % first row 4 | cmap(2, :) = colour_b; % middle row 5 | cmap(3, :) = colour_c; % last row 6 | 7 | [X,Y] = meshgrid([1:3],[1:num_colours]); % mesh of indices 8 | 9 | cmap = interp2(X([1, round(num_colours/2), num_colours],:),Y([1, round(num_colours/2), num_colours],:), cmap, X, Y); % interpolate colormap 10 | end 11 | 12 | % function interpolated_colourmap() -------------------------------------------------------------------------------- /utils/vis/make_streams_uniform.m: -------------------------------------------------------------------------------- 1 | function verts = make_streams_uniform(verts) 2 | 3 | % Remove nan vertices from streamlines (points outside the convex hull) 4 | verts = cellfun(@remove_nans, verts, 'UniformOutput', false); 5 | % Make all streamlines of the same length so we can use streamparticles 6 | stream_lengths = cellfun(@(c) size(c, 1), verts); 7 | max_length = max(stream_lengths); 8 | wrap_func = @(verts) add_vertices(verts, max_length); 9 | verts = cellfun(wrap_func, verts, 'UniformOutput', false); 10 | 11 | end % function make_streams_uniform() 12 | 13 | function x = remove_nans(x) 14 | % Dummy function to be call by cellfun 15 | x(isnan(x)) = []; 16 | 17 | end % function remove_nans() 18 | -------------------------------------------------------------------------------- /utils/vis/standardise_range.m: -------------------------------------------------------------------------------- 1 | %% Rescales data to a given inclusive range, defaults to [0, 1]. 2 | % 3 | % ARGUMENTS: 4 | % data -- nD array in the range [min value, max value] 5 | % new_range -- 2 element vector [min, max] with the new (inclusive) range. 6 | % 7 | % OUTPUT: 8 | % data -- Rescaled data in the range [min, max]. 9 | % 10 | % AUTHOR: 11 | % Paula Sanz-Leon (2018-12-21). 12 | % 13 | % USAGE: 14 | %{ 15 | 16 | %} 17 | % NOTES: See https://scikit-learn.org/stable/modules/preprocessing.html 18 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 19 | 20 | function data = standardise_range(data, new_range) 21 | if nargin < 1 || isempty(data) 22 | error(['PSL:' mfilename ':BadArgs'], ... 23 | 'Argument 1, the data to standardise, must be provided.'); 24 | end 25 | if nargin > 1 && ~isempty(new_range) && (numel(new_range) ~= 2) 26 | error(['PSL:' mfilename ':BadArgs'], ... 27 | 'Argument 2, new_range, must be a two element vector.'); 28 | end 29 | 30 | min_val = min(data(:)); 31 | max_val = max(data(:)); 32 | if min_val == max_val 33 | error(['PSL:' mfilename ':UniformData'], ... 34 | 'Cannot standardise data consisting of only one value.'); 35 | end 36 | 37 | % Rescale to range [0,1] 38 | data = (data - min_val) / (max_val - min_val); 39 | 40 | if nargin > 1 && ~isempty(new_range) 41 | % Rescale to range new_range 42 | data = data * (new_range(2) - new_range(1)) + new_range(1); 43 | end 44 | 45 | end % function standardise_range() 46 | -------------------------------------------------------------------------------- /utils/vis/using_hg2.m: -------------------------------------------------------------------------------- 1 | %USING_HG2 Determine if the HG2 graphics engine is used 2 | % 3 | % tf = using_hg2(fig) 4 | % 5 | %IN: 6 | % fig - handle to the figure in question. 7 | % 8 | %OUT: 9 | % tf - boolean indicating whether the HG2 graphics engine is being used 10 | % (true) or not (false). 11 | 12 | % 19/06/2015 - Suppress warning in R2015b; cache result for improved performance 13 | % 06/06/2016 - Fixed issue #156 (bad return value in R2016b) 14 | 15 | function tf = using_hg2(fig) 16 | persistent tf_cached 17 | if isempty(tf_cached) 18 | try 19 | if nargin < 1, fig = figure('visible','off'); end 20 | oldWarn = warning('off','MATLAB:graphicsversion:GraphicsVersionRemoval'); 21 | try 22 | % This generates a [supressed] warning in R2015b: 23 | tf = ~graphicsversion(fig, 'handlegraphics'); 24 | catch 25 | tf = ~verLessThan('matlab','8.4'); % =R2014b 26 | end 27 | warning(oldWarn); 28 | catch 29 | tf = false; 30 | end 31 | if nargin < 1, delete(fig); end 32 | tf_cached = tf; 33 | else 34 | tf = tf_cached; 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /visualisation/convex_hull_lh_513parc.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/visualisation/convex_hull_lh_513parc.mat -------------------------------------------------------------------------------- /visualisation/convex_hull_lh_513parc_projections.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brain-modelling-group/neural-flows/b4c1752aaa4ea3d78dd60a02bd9cba4a5d93257d/visualisation/convex_hull_lh_513parc_projections.mat -------------------------------------------------------------------------------- /visualisation/main_visualisation.m: -------------------------------------------------------------------------------- 1 | function ouparams = main_visualisation(inparams) 2 | %% Wrapper function to perform basic visualisation: 3 | % People can write their own main_visualisation function calling different combinations of 4 | % plotting functions 5 | 6 | display_info_banner(mfilename, 'STARTED VISUALISATION', '#966797', false) 7 | %---------------------------------DECOMPOSITION--------------------------------% 8 | if inparams.flows.visualisation.enabled 9 | %plot1d_speed_distribution(inparams); 10 | plot2d_svd_modes(inparams); 11 | end 12 | %---------------------------SINGULARITY----------------------------------------% 13 | if inparams.singularity.visualisation.enabled 14 | plot3d_singularity_temporal_occupancy(inparams); 15 | plot2d_singularity_tracking_cross_stitch(inparams); 16 | plot1d_singularity_relative_temporal_occupancy(inparams); 17 | plot1d_singularity_relative_spatial_occupancy(inparams); 18 | plot1d_singularity_traces_sandplot(inparams); 19 | plot1d_singularity_stats(inparams); 20 | plotcomp_singularity_absolute_occupancy(inparams); 21 | end 22 | %------------------------------------------------------------------------------% 23 | % TODO: write output parameters if required 24 | display_info_banner(mfilename, 'FINISHED VISUALISATION', '#966797', false) 25 | 26 | end % function main_analysis() 27 | -------------------------------------------------------------------------------- /visualisation/make_movie_gif.m: -------------------------------------------------------------------------------- 1 | function make_movie_gif(data, save_anim, cmap) 2 | 3 | % data should be (time, space dim 1, space dim 2) 4 | % save_anim boolean, 0 - do not save, 1 save animation in gif 5 | 6 | % ===================================================================== 7 | if nargin < 2 8 | save_anim = 0; 9 | cmap = parula; 10 | end 11 | % Enter file name 12 | temp_fname = generate_temp_filename('gif_anim', 3); 13 | anim_name = [temp_fname 'gif']; 14 | 15 | % Delay in seconds before displaying the next image 16 | delay = 0; 17 | % Frame counter start 18 | 19 | nt = 1; 20 | tpts = size(data, 1); 21 | 22 | 23 | fig_gif = figure('Name', 'nflows-gifanim'); 24 | these_axes = subplot(1,1,1, 'Parent', fig_gif); 25 | these_axes.Visible = 'off'; 26 | pos = [0.6 0.05 0.35 0.40]; 27 | set(gcf,'Units','normalized'); 28 | set(gcf,'Position',pos); 29 | set(gcf,'color','w'); 30 | 31 | for cc =1:tpts 32 | xy = squeeze(data(cc, :, :)); 33 | h = pcolor(these_axes, xy); 34 | h.FaceColor = 'interp'; 35 | h.EdgeColor = 'none'; 36 | % NOTE: these parameters should be passed as options 37 | colormap(cmap) 38 | %colormap(hsv(1024)) 39 | %caxis([-40 10]) 40 | these_axes.Title.String = ['Time frame: ' num2str(cc, '%04d')]; 41 | 42 | if save_anim == 1 43 | frame = getframe(these_axes); 44 | im = frame2im(frame); 45 | [imind,cm] = rgb2ind(im, 256); 46 | % On the first loop, create the file. In subsequent loops, append. 47 | if nt == 1 48 | imwrite(imind, cm, anim_name,'gif','DelayTime', delay,'loopcount',inf); 49 | else 50 | imwrite(imind, cm, anim_name,'gif','DelayTime', delay,'writemode','append'); 51 | end 52 | nt = nt+1; 53 | end 54 | pause(1) 55 | end 56 | 57 | end % make_movie_gif() 58 | -------------------------------------------------------------------------------- /visualisation/plot1d_flows_ts.m: -------------------------------------------------------------------------------- 1 | function ax_handle = plot1d_flows_ts(obj_flows, ax_handle) 2 | 3 | if nargin < 2 4 | ax_handle = axes; 5 | end 6 | 7 | num_points = obj_flows.num_innies; 8 | figure_handle = figure('Name', 'nflows-flows-average-over-time', varargin{:}); 9 | 10 | 11 | hold(ax_handle, 'on') 12 | plot(ax_handle, obj_flows.sum_ux/num_points, 'r') 13 | plot(ax_handle, obj_flows.sum_uy/num_points, 'g') 14 | plot(ax_handle, obj_flows.sum_uz/num_points, 'b') 15 | ax_handle.XLabel.String = 'time/samples' 16 | ax_handle.YLabel.String = 'u_{x, y, z}' 17 | 18 | end % function plot1d_flows_ts() -------------------------------------------------------------------------------- /visualisation/plot1d_singularity_stats.m: -------------------------------------------------------------------------------- 1 | function figure_handles = plot1d_singularity_stats(inparams) 2 | % Composite plotting function to display histograms and traces of each 3 | % singularity over time 4 | 5 | obj_sings = load_iomat_singularity(inparams); 6 | 7 | if inparams.singularity.quantification.nodal_occupancy.enabled 8 | singularity_count = squeeze(sum(obj_sings.tracking_3d_matrix, 2)).'; 9 | else 10 | singularity_count = obj_sings.count; 11 | end 12 | figure_handles{1} = plot1d_singularity_traces_counts(singularity_count); 13 | figure_handles{2} = plot1d_singularity_histograms(singularity_count); 14 | 15 | end % function plot1d_singularity_stats() -------------------------------------------------------------------------------- /visualisation/plot1d_speed_distribution.m: -------------------------------------------------------------------------------- 1 | function figure_handle = plot1d_speed_distribution(params, varargin) 2 | % varargin -- for the time being a 1 x 2 cell array with 3 | % {'Visible', 'off'}: 4 | 5 | obj_flows = load_iomat_flows(params); 6 | 7 | numsubplot = 2; 8 | figure_handle = figure('Name', 'nflows-speed-distribution', varargin{:}); 9 | ax = gobjects(numsubplot); 10 | 11 | for jj=1:numsubplot 12 | ax(jj) = subplot(1, numsubplot, jj, 'Parent', figure_handle); 13 | hold(ax(jj), 'on') 14 | end 15 | 16 | if strcmp(params.flows.modality, 'amplitude') 17 | uxyz = obj_flows.uxyz; 18 | else 19 | uxyz(:, 1, :) = obj_flows.vx; 20 | uxyz(:, 2, :) = obj_flows.vy; 21 | uxyz(:, 3, :) = obj_flows.vz; 22 | end 23 | 24 | % Norm 25 | un = squeeze(sqrt(uxyz(:, 1, :).^2+uxyz(:, 2, :).^2+uxyz(:, 3, :).^2)); 26 | 27 | hh(1) = histogram(ax(1), un, 'Normalization', 'probability'); 28 | hh(2) = histogram(ax(2), log10(un), 'Normalization', 'probability'); 29 | 30 | for jj=1:numsubplot 31 | hh(jj).EdgeColor = 'none'; 32 | hh(jj).FaceAlpha = 0.5; 33 | ax(jj).YLabel.String = 'probability'; 34 | end 35 | 36 | ax(1).XLabel.String = ['speed [' params.data.resolution.units.space '/' params.data.resolution.units.time ']']; 37 | ax(2).XLabel.String = ['log_{10}(speed) [' params.data.resolution.units.space '/' params.data.resolution.units.time ']']; 38 | ax(1).Box = 'on'; 39 | ax(2).Box = 'on'; 40 | 41 | end -------------------------------------------------------------------------------- /visualisation/plot2d_cohcorrgram.m: -------------------------------------------------------------------------------- 1 | function fig_handle = plot2d_cohcorrgram(cohcorrgram_struct) 2 | 3 | % TODOC: 4 | %figure('position',[360 748 1200 200]) 5 | cmap = bluegred(256); 6 | imagesc(cohcorrgram_struct.ct, cohcorrgram_struct.cl, cohcorrgram_struct.cc) 7 | set(gca,'YDir','normal') 8 | xlabel(strcat('t [', cohcorrgram_struct.str_units, ']')) 9 | ylabel(strcat('lag [', cohcorrgram_struct.str_units, ']')) 10 | caxis([-1 1]) 11 | colormap(cmap); 12 | cbar = colorbar; 13 | ylabel(cbar,'cc') 14 | 15 | end % function plot2d_cohcorrgram() 16 | -------------------------------------------------------------------------------- /visualisation/plot2d_svd_modes.m: -------------------------------------------------------------------------------- 1 | function fig_handle = plot2d_svd_modes(params) 2 | % wrapper function 3 | 4 | % Lod necessary data 5 | obj_flows = load_iomat_flows(params); 6 | svd_data = obj_flows.flow_modes; 7 | 8 | % Define a few vecs we need 9 | time_vec = params.data.resolution.ht:params.data.resolution.ht:params.flows.data.shape.t*params.data.resolution.ht; 10 | fig_handle = plot_svd_modes(svd_data.V, svd_data.U, ... 11 | svd_data.XYZ.X, svd_data.XYZ.Y, svd_data.XYZ.Z, ... 12 | svd_data.prct_var, params.flows.decomposition.svd.modes, ... 13 | time_vec); 14 | end % function plot2d_svd_modes() -------------------------------------------------------------------------------- /visualisation/plot3d_debug_data_frame.m: -------------------------------------------------------------------------------- 1 | function fig_handle = plot3d_debug_data_frame(fig_handle, data, X, Y, Z, time) 2 | 3 | 4 | if isempty(fig_handle) 5 | fig_handle = figure('Name', 'nflows-plot3d-debug-wave-frame') 6 | end 7 | 8 | 9 | if length(size(data)) == 4 10 | tt = 1; 11 | %colormap(bluegred(256)) 12 | pcolor3(X, Y, Z, squeeze(data(:, :, :, tt)), 'fig', fig_handle); 13 | colormap(bluegred(256)) 14 | ylabel('Y') 15 | xlabel('X') 16 | zlabel('Z') 17 | 18 | % figure('Name', 'nflows-planewave3d-time') 19 | % plot(time, wave2d, 'color', [0.0 0.0 0.0 0.5]); 20 | % xlabel('time') 21 | % ylabel('p(x, y, z)') 22 | else 23 | tt = 1; 24 | these_axes = subplot(1,1,1, 'Parent', fig_handle); 25 | scatter3(data(tt, :)); 26 | colormap(bluegred(256)) 27 | ylabel('Y') 28 | xlabel('X') 29 | zlabel('Z') 30 | end 31 | 32 | 33 | end -------------------------------------------------------------------------------- /visualisation/plot3d_flow_frame.m: -------------------------------------------------------------------------------- 1 | function fig_handle = plot3d_flow_frame(fig_handle, ux, uy, uz, X, Y, Z) 2 | 3 | if isempty(fig_handle) 4 | fig_handle = figure('Name', 'nflows-flow-frame'); 5 | end 6 | 7 | for kk=1:4 8 | ax(kk) = subplot(2, 2, kk, 'Parent', fig_handle); 9 | ax(kk).XLabel.String = 'x'; 10 | ax(kk).YLabel.String = 'y'; 11 | ax(kk).ZLabel.String = 'z'; 12 | ax(kk).View = [-37.5 30]; 13 | end 14 | 15 | % Norm 16 | unorm = sqrt(ux.^2 + uy.^2 + uz.^2); 17 | 18 | hcone = coneplot(ax(1), X, Y, Z, ux, uy, uz, X, Y, Z, unorm); 19 | camlight right 20 | lighting gouraud 21 | hcone_ux = coneplot(ax(2), X, Y, Z, ux, uy, uz, X, Y, Z, ux); 22 | ax(2).Colormap = bluegred(256); 23 | ax(2).CLim = [-1.5 1.5]; 24 | 25 | 26 | camlight right 27 | lighting gouraud 28 | hcone_uy = coneplot(ax(3), X, Y, Z, ux, uy, uz, X, Y, Z, uy); 29 | ax(3).Colormap = bluegred(256); 30 | ax(3).CLim = [-1.5 1.5]; 31 | camlight right 32 | lighting gouraud 33 | 34 | hcone_uz = coneplot(ax(4), X, Y, Z, ux, uy, uz, X, Y, Z, uz); 35 | ax(4).Colormap = bluegred(256); 36 | ax(4).CLim = [-1.5 1.5]; 37 | camlight right 38 | lighting gouraud 39 | 40 | set(hcone,'EdgeColor','none'); 41 | set(hcone_ux,'EdgeColor','none'); 42 | set(hcone_uy,'EdgeColor','none'); 43 | set(hcone_uz,'EdgeColor','none'); 44 | 45 | 46 | hcone.DiffuseStrength = 0.8; 47 | hcone_ux.DiffuseStrength = 0.8; 48 | hcone_uy.DiffuseStrength = 0.8; 49 | hcone_uz.DiffuseStrength = 0.8; 50 | 51 | end % function plot3d_flow_frame() 52 | -------------------------------------------------------------------------------- /visualisation/plot3d_flows_ts.m: -------------------------------------------------------------------------------- 1 | function ax_handle = plot3d_flows_ts(obj_flows, ax_handle) 2 | 3 | if nargin < 2 4 | ax_handle = axes; 5 | end 6 | 7 | num_points = obj_flows.num_innies; 8 | figure_handle = figure('Name', 'nflows-flows-average-ux-uy-uz', varargin{:}); 9 | 10 | 11 | hold(ax_handle, 'on') 12 | 13 | plot3(ax_handle, obj_flows.sum_ux(1,1)/num_points, obj_flows.sum_uy(1,1)/num_points, obj_flows.sum_uz(1,1)/num_points, ... 14 | '.', 'markerfacecolor', 'b', 'markersize', 20) 15 | plot3(ax_handle, obj_flows.sum_ux(1,end)/num_points, obj_flows.sum_uy(1,end)/num_points, obj_flows.sum_uz(1,end)/num_points, ... 16 | '.', 'markerfacecolor', 'r', 'markersize', 20) 17 | 18 | plot3(ax_handle, obj_flows.sum_ux/num_points, obj_flows.sum_uy/num_points, obj_flows.sum_uz/num_points) 19 | 20 | 21 | end % function plot3d_flows_ts() -------------------------------------------------------------------------------- /visualisation/plot3d_nodal_streamlines.m: -------------------------------------------------------------------------------- 1 | function plot3d_nodal_streamlines(obj_streams) 2 | 3 | 4 | locs = obj_streams.seeding_locs; 5 | 6 | 7 | % Start locations 8 | plot3(locs(:, 1), locs(:, 2), locs(:, 3), 'k.') 9 | hold on 10 | 11 | for tt = 1:10 12 | temp_frame = obj_streams.streamlines(1, tt); 13 | streams = temp_frame.paths; 14 | 15 | for ii=1:length(streams) 16 | plot3(squeeze(streams{ii}(:, 1)), ... 17 | squeeze(streams{ii}(:, 2)), ... 18 | squeeze(streams{ii}(:, 3)), 'color', [0.5 0.5 0.5 0.1]); 19 | plot3(squeeze(streams{ii}(end, 1)), ... 20 | squeeze(streams{ii}(end, 2)), ... 21 | squeeze(streams{ii}(end, 3)), '.', 'markeredgecolor', [1 0.0 0.0], 'markersize', 0.042); 22 | end 23 | end 24 | end % function plot3d_nodal_streamlines() -------------------------------------------------------------------------------- /visualisation/plot3d_pathlines.m: -------------------------------------------------------------------------------- 1 | function plot3d_pathlines(obj_streams) 2 | 3 | node_locs = obj_streams.locs; 4 | locs = obj_streams.initial_seeding_locs; 5 | pathlines = obj_streams.pathlines; 6 | these_locs_idx = 1:4:length(pathlines); 7 | 8 | % Start locations 9 | fig_handle = figure('Name', 'neural-flows-pathlines'); 10 | 11 | [ax, ~] = tight_subplot(1, 3); 12 | 13 | ax(1).Parent = fig_handle; 14 | ax(2).Parent = fig_handle; 15 | ax(3).Parent = fig_handle; 16 | 17 | for kk=1:3 18 | hold(ax(kk), 'on') 19 | %ax(kk).DataAspectRatio = [1 1 1]; 20 | plot3(ax(kk), locs(these_locs_idx, 1), locs(these_locs_idx, 2), locs(these_locs_idx, 3), 'ro', 'markeredgecolor', 'r', 'markerfacecolor', 'r', 'markersize', 4.2) 21 | scatter3(ax(kk), node_locs(:, 1), node_locs(:, 2), node_locs(:, 3), 100, [0.5 0.5 0.5], 'filled', 'markeredgecolor', 'none', 'markerfacealpha', 0.2) 22 | axis(ax(kk), 'off') 23 | end 24 | 25 | for ii=1:4:length(pathlines) 26 | for kk=1:3 27 | plot3(ax(kk), squeeze(pathlines{ii}(:, 1)), ... 28 | squeeze(pathlines{ii}(:, 2)), ... 29 | squeeze(pathlines{ii}(:, 3)), 'color', [0 0 0 0.5], 'linewidth', 0.5); 30 | plot3(ax(kk), squeeze(pathlines{ii}(end, 1)), ... 31 | squeeze(pathlines{ii}(end, 2)), ... 32 | squeeze(pathlines{ii}(end, 3)), 'bo', 'markeredgecolor', 'b', 'markerfacecolor', 'b', 'markersize', 4.2); 33 | end 34 | end 35 | 36 | ax(1).View = [0 90]; 37 | ax(1).DataAspectRatio = [1 1 1]; 38 | ax(2).View = [0 0]; 39 | ax(2).DataAspectRatio = [1 1 1]; 40 | ax(3).View = [90 0]; 41 | ax(3).DataAspectRatio = [1 1 1]; 42 | 43 | end % function plot3d_pathlines() 44 | -------------------------------------------------------------------------------- /visualisation/plot3d_pathlines_coloured.m: -------------------------------------------------------------------------------- 1 | function plot3d_pathlines_coloured(obj_streams) 2 | 3 | 4 | locs = obj_streams.initial_seeding_locs; 5 | 6 | % Start locations 7 | fig_handle = figure('Name', 'neural-flows-pathlines-coloured'); 8 | ax = subplot(1,1,1, 'Parent', fig_handle); 9 | ax.Color = [1 1 1]; 10 | hold(ax, 'on') 11 | ax.CLim = [0, 1]; 12 | cmap = magma(256); 13 | ax.Colormap = cmap; 14 | c_ref = linspace(0,1,256); 15 | pathlines = obj_streams.pathlines; 16 | plot3(ax, locs(:, 1), locs(:, 2), locs(:, 3), 'k.') 17 | 18 | for ii=1:4:length(pathlines) 19 | x = squeeze(pathlines{ii}(:, 1)); 20 | y = squeeze(pathlines{ii}(:, 2)); 21 | z = squeeze(pathlines{ii}(:, 3)); 22 | if length(x) < 600 23 | continue 24 | end 25 | t = linspace(0, 1, length(x)); 26 | c = imquantize(t, c_ref); 27 | line_color = cmap(c, :); 28 | line_color = reshape(line_color, length(x), 1, 3); 29 | line_colormap = cat(2, line_color, line_color); 30 | color_line3(x, y, z, line_colormap, '.'); 31 | end 32 | end % function plot3d_pathlines_coloured() -------------------------------------------------------------------------------- /visualisation/plot3d_pcolor3_movie.m: -------------------------------------------------------------------------------- 1 | function [fig_handle] = plot3d_pcolor3_movie(fig_handle, X, Y, Z, V) 2 | 3 | % Plots volumetric data over time - memory consuming 4 | % V is a 4D array, where the three frost dimensions are spatial dimensions 5 | % and time is the fourth diemnsions 6 | 7 | 8 | if isempty(fig_handle) 9 | fig_handle = figure('Name', 'nflows-pcolor3-movie'); 10 | %fig_handle.Position = [31.6442 10.0013 29.5010 22.5954]; 11 | end 12 | 13 | crange=quantile(V(1:100:end),[0.001 0.999]); 14 | max_val = max(abs(crange)); 15 | 16 | time = 1:size(V, 4); 17 | 18 | colormap(redyellowblue(256, 'rev')) 19 | colorbar 20 | 21 | try 22 | vidfile = VideoWriter('pcolor3_movie.mp4','MPEG-4'); 23 | catch 24 | vidfile = VideoWriter('pcolor3_movie.avi'); 25 | end 26 | vidfile.FrameRate = 15; 27 | open(vidfile); 28 | 29 | for tt=1:length(time) 30 | these_axes = subplot(1, 1, 1, 'Parent', fig_handle); 31 | colorbar(these_axes) 32 | these_axes.XLabel.String = 'X'; 33 | these_axes.YLabel.String = 'Y'; 34 | these_axes.ZLabel.String = 'Z'; 35 | cla; 36 | pcolor3(X, Y, Z, squeeze(V(:, :, :, tt)), 'axes', these_axes, 'fig', fig_handle); 37 | axis off 38 | title(['Time:' num2str(time(tt), '%.3f') ' ms']) 39 | view([0 90]) 40 | %view([0 0]) 41 | %view([90 0]) 42 | caxis([crange]); 43 | pause(0.01); 44 | writeVideo(vidfile, getframe(fig_handle)); 45 | end 46 | close(vidfile) 47 | 48 | end % function plot3d_pcolor3_movie() -------------------------------------------------------------------------------- /visualisation/plot3d_singularity_temporal_occupancy.m: -------------------------------------------------------------------------------- 1 | function fig_handles = plot3d_singularity_temporal_occupancy(params) 2 | 3 | obj_singularity = load_iomat_singularity(params); 4 | % TODO: configiure graphics property to handle paper units so we can plot 5 | % stuff and give figure sizes 6 | cmap = s3d_get_colours('critical-points'); 7 | num_base_sngs = size(obj_singularity, 'tracking_3d_matrix', 1); 8 | total_frames = size(obj_singularity, 'tracking_3d_matrix', 3); 9 | 10 | % Load data to plot 11 | nodal_singularity_summary = obj_singularity.nodal_singularity_summary; 12 | 13 | fig_handles = plot_spheres(); 14 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Plotting functions %%%%%%%%%%%%%%%%%%%%%%% 15 | function fig_handles = plot_spheres() 16 | 17 | color_a = [0 0 0]; 18 | fig_handles = cell(num_base_sngs, 1); 19 | for kk=1:num_base_sngs 20 | data = nodal_singularity_summary.occupancy_partial(kk, :) / total_frames; 21 | color_c = cmap(kk, :); 22 | color_b = color_c/2; 23 | color_map = interpolated_colourmap(color_a, color_b, color_c, 64); 24 | sizedata = data; 25 | sizedata(sizedata > 0) = 4; 26 | sizedata(sizedata == 0)= 1; 27 | min_val = 0.0; 28 | max_val = max(data)*100; 29 | [fig_handles{kk}] = plot_sphereanim(data*100, obj_singularity.locs, 1, [min_val max_val], color_map, 'handle', sizedata); 30 | fig_handles{kk}.Children(2).Visible = 'off'; 31 | end 32 | end % function plot_spheres() 33 | 34 | end % function plot3d_singularity_local_occupancy() 35 | -------------------------------------------------------------------------------- /visualisation/plot3d_streamparticles.m: -------------------------------------------------------------------------------- 1 | function fig_handle = plot3d_streamparticles(params, these_frames, display_modality) 2 | % params: structure with all the parameters for neural-flows 3 | % these_frames vector with indices of time frames to plot 4 | % display_modality = "workspace" or "movie" 5 | 6 | if nargin < 3 7 | display_modality = "workspace"; 8 | end 9 | % Set info we need 10 | %these_frames = params.stremalines.visualisation.particles.frames; 11 | %params.stremalines.visualisation.particles.display.modality; 12 | %these_frames = [174]; 13 | %these_frames = [50]; 14 | 15 | % Load file handles 16 | obj_flows = load_iomat_flows(params); 17 | obj_streams = load_iomat_streams(params); 18 | 19 | % Load info we need for visualisation 20 | xyz_lims = obj_flows.xyz_lims; 21 | num_frames = length(these_frames); 22 | fig_handle = cell(num_frames, 1); 23 | axs_handle = cell(num_frames, 1); 24 | 25 | for ff=1:num_frames 26 | stream_verts = get_verts(these_frames(ff)); 27 | fig_handle{ff} = figure('Name', 'nflows-flows-streamparticles-mb'); 28 | axs_handle{ff} = p3_streamparticles(fig_handle{ff}, stream_verts, xyz_lims, display_modality); 29 | end 30 | 31 | function verts = get_verts(idx) 32 | tmp = obj_streams.streamlines(1, idx); 33 | verts = tmp.paths; 34 | verts = make_streams_uniform(verts); 35 | end % get_verts() 36 | 37 | end % function plot3d_streamparticles() 38 | -------------------------------------------------------------------------------- /visualisation/plot_debug_flow_histogram.m: -------------------------------------------------------------------------------- 1 | function plot_debug_flow_histogram(fig_handle, obj_flows, params) 2 | 3 | 4 | switch params.flows.method.data.mode 5 | case {'amplitude'} 6 | switch params.data.grid.type 7 | 8 | case {'structured'} 9 | ux = obj_flows.ux(2:end-1, 2:end-1, 2:end-1, :); 10 | uy = obj_flows.uy(2:end-1, 2:end-1, 2:end-1, :); 11 | uz = obj_flows.uz(2:end-1, 2:end-1, 2:end-1, :); 12 | un = obj_flows.un(2:end-1, 2:end-1, 2:end-1, :); 13 | 14 | case {'unstructured'} 15 | ux = obj_flows.uxyz(:, 1, :); 16 | uy = obj_flows.uxyz(:, 2, :); 17 | uz = obj_flows.uxyz(:, 3, :); 18 | un = obj_flows.uxyz_n; 19 | end 20 | case {'phase'} 21 | ux = obj_flows.vx; 22 | uy = obj_flows.vy; 23 | uz = obj_flows.vz; 24 | un = obj_flows.vn; 25 | end 26 | 27 | unit_label = strcat('[', params.data.units.space, '/', ... 28 | params.data.units.time, ']'); 29 | 30 | subplot(1, 4, 1, 'Parent', fig_handle) 31 | hist_handle(1) = histogram(ux(:), 'Normalization', 'pdf'); 32 | xlabel(strcat('ux ', unit_label)) 33 | 34 | subplot(1, 4, 2, 'Parent', fig_handle) 35 | hist_handle(2) = histogram(uy(:), 'Normalization', 'pdf'); 36 | xlabel(strcat('uy ', unit_label)) 37 | 38 | subplot(1, 4, 3, 'Parent', fig_handle) 39 | hist_handle(3) = histogram(uz(:), 'Normalization', 'pdf'); 40 | xlabel(strcat('uz ', unit_label)) 41 | 42 | subplot(1, 4, 4, 'Parent', fig_handle) 43 | hist_handle(4) = histogram(un(:), 'Normalization', 'pdf'); 44 | xlabel(strcat('u_{norm} ', unit_label)) 45 | 46 | for hh=1:length(hist_handle) 47 | hist_handle(hh).EdgeColor = [0.5 0.5 0.5]; 48 | hist_handle(hh).FaceColor = [0.5 0.5 0.5]; 49 | end 50 | 51 | end %function plot_debug_flow_histogram --------------------------------------------------------------------------------