| 9 | |
| 10 | |
| 11 | def normalize_data_3D(strands_data, mean, std): |
| 12 | # print("strands_data ",strands_data.shape) |
| 13 | orig_shape = strands_data.shape |
| 14 | nr_strands = strands_data.shape[0] |
| 15 | nr_elements_spatial_dim = strands_data.shape[1] |
| 16 | strands_data=strands_data.view(nr_strands, nr_elements_spatial_dim, -1) |
| 17 | # print("strands_data ",strands_data.shape) |
| 18 | # print("mean ",mean.shape) |
| 19 | strands_data=strands_data-mean.view(1,1,-1) |
| 20 | strands_data=strands_data/(std.view(1,1,-1)+1e-6) |
| 21 | |
| 22 | #checks which elements are zero in the std and just set them to zero because they are basically noise |
| 23 | valid=std.view(1,1,-1)>=1e-9 |
| 24 | strands_data=strands_data*valid |
| 25 | |
| 26 | strands_data=strands_data.view(orig_shape) |
| 27 | return strands_data |
| 28 | |
| 29 | def normalize_data_2D(strands_data, mean, std): |
| 30 | # print("strands_data ",strands_data.shape) |