Repository navigation
Conversation
- add dependency explicitly (previously included implicitly via properties->roi->image->header), - and remove duplicate include.
…and adapt commands accordingly.
…ion from streamline-reading. Introduce properties_consensus method, based on tckedit's current implementation, to find a consensus between multiple header information. Extend Tractography::Reader to support multiple tracks files by default (and associated weights files).
|
Looks like maximum build-time was exceeded on AppVeyor. On my side, the PR |
Yep, happens sometimes. It's a bit hit and miss. I just restarted the AppVeyor build. Don't worry about it, it'll get there eventually. Travis CI already tells us that all is well. 😉 |
|
I think there might potentially be a bug with I will try and put together mcve for this, but in a nutshell; I obtain significantly different connectivity matrices using I have checked thoroughly that this was not due to an error introduced in this PR, or to the way that I split the SIFT2 weights; instead, the only way to obtain the exact same connectivity matrices appears to be by setting EDIT: It is not due to the way that I split the SIFT2 weights, but to the way that they should be merged... I just realised that merging the smaller TL;DR: this is how to merge multiple tracks files with associated SIFT2 weights |
I'm not sure there needs to be any stringent requirement for such a file extension; for instance, commands like It should be possible to load track data with a series of try/except clauses: Try to load the input as a The only downside to this I see currently is that it would no longer be possible to perform as stringent sanity checking when an
There is already a paragraph in the Description section of multiple commands (including There's also been at least one discussion around here somewhere regarding the handling of SIFT2 weights, in particular whether they should be embedded within the track data (technically possible without breaking backward compatibility with the Indeed in the context of BIDS Derivatives development I raised the prospect of doing something similar to the fixel directory format: Split the header key-value contents into e.g. a JSON file, have track data stored in binary format in some file with a fixed name, and any additional data files (whether providing a value per vertex, like in Not necessarily pushing the narrative in one direction or the other here; just exposing some thinking in case it highlights a potential solution that may otherwise be missed. |
…ed Editing::Worker/Receiver implementations. Use at instead of [] to throw exception if property does not exist.
|
Apologies for the mess with force-push / close-reopen; I didn't intend to modify the submodule in
From my perspective, it's not a matter of need so much as an issue of clarity. Of course, these are just plain text files, and extensions in general are artificial. But let's take the command in my previous message as an example: would become, replacing It's hard for me to imagine that anyone would find the latter less confusing:
Having a separate extension makes it clear, even without knowing much, that
That was just me being tired; I should have realised this long before I started calling it a bug, sorry. It's a non-trivial gotcha, but the previous command is simple enough to remember, and you only make that mistake once.
I think including weights and additional information within the I find the simplicity of On the contrary, I 😍 the idea of using folders as data structures. It makes so much more sense to exploit the file-system's ability to structure data hierarchically, rather than say, to work with complicated formats like |
All good, it's not really that difficult to figure out since everything ends up tracked and cross-linked. Mistakes get made all the time with the testing submodule so no biggie there.
No argument against the observation that it's more clear. But we try to not place arbitrary restrictions on the user; the fact that using a text file with any extension would theoretically work, as long as it contains a list of file names (which is easy to check), makes it hard to justify not permitting such; and the fact that there are other existing commands that already accept a text file containing a list of file names where no such extension restriction exists means that the issue is more likely to be encountered by / confusing for users. One advantage gained from such a restriction is the ability to do a preliminary check on the user input during command-line parsing. However this would likely be altered upon addressing #411 anyway: I'd expect that something similar to image format handling would occur, where each format is queried in turn to see if it can read the input data; a handler that interprets a list of file names would simply be one particular instance of such, and would require a preliminary scan of the contents of the file, just as is required when a directory is provided as an input image to determine whether or not it contains DICOM data.
Technically, as long as the file either contains a vector of values, or a list of file names (each of which contains a vector of values), whether or not the input track data are stored in a single file or across multiple files (and whether or not that is consistent with how the weights data are stored) is not actually crucial for reading in the weights. There are already warnings issued if the number of streamline weights read is more or less than the number of streamlines, which would be enough to catch egregious misuses. Beyond that, the only issue is whether or not the order of the data are consistent between tracks and weights, and that is up to the user to manage. But I'm not sure that the weights data should have to be split across multiple files if that's how the track data are stored, nor vice-versa; both can be reasonably read in isolation, with having the same cardinality in both sources being the only stringent constraint. I suppose the ambiguity that this would raise would be running the
Well, I'm not wholly convinced: I don't know how common it might be that users run their commands as such and simply don't interrogate the output very closely. The description section is not very "loud". I'd feel much more comfortable with the underlying mechanism resolved... @jdtournier worth bumping for RC4?
I agree. I don't recall exactly where the discussion took place, but essentially the observation was that each streamline is delimited by a triplet of NaNs, so one of those three NaNs could be "co-opted" to carry the streamline weight, and the delimitation would still be detectable. But:
If that does get pursued, I would expect that it would be in the BIDS Derivatives context rather than the MRtrix3 context. |
70031c3 to
6bf4cec
Compare
|
Similarly to #3281, I think this one is going to be dropped in favour of #3415. #3415 includes a tractogram "file format" that involves sending binary data through Unix pipes. This enables the With other goings-on in #3415 it then additionally has the capability to integrate data-per-streamline and data-per-vertex into the content of that piped data. This alleviates the issue recognised with the approach implemented here in that one may want to concatenate both streamline vertex and sidecar data, and the order of concatenation must be consistent and there should be some convenient interface by which to do so. If those sidecar data are embedded within the tractogram file format for each dataset individually then they should be preserved through the concatenation operation, and each dataset must only be specified once which mitigates against ordering errors. The TRX format that motivated the effort in #3415 also makes use of the concept raised here of embedding tractogram sidecar within a directory structure (or indeed compressed / uncompressed tarballs), which can alleviate sidecar data correspondence issues similar to those discussed here in the absence of dataset concatenation. If it were to be the case that despite changes in #3415 there is still nevertheless utility in having the ability to specify "an input tractogram" that is actually a text file containing a list of tractogram files to be treated as a singular dataset, then rather than attempting to integrate the change here, that should instead be implemented from scratch as an extension of #3415. It would actually be far more elegant there.
|
This PR follows from #1569 and #1567.
It is an enhancement of the existing code to support multiple input
.tckfiles for commands that currently accept.tckfiles:.lst(for "list"), containing one filename per line. These can be used either in place of.tckarguments, or in place of weights files (e.g. option-tck_weights_in)..lstfiles are not involved.Implementation
The changes mainly consist in a re-write of the class
Tractography::Reader, which now holds astd::vectorof tracks filenames (and optionally of weights filenames too). TheReaderInterfaceis preserved: theoperator()method implemented inReadersimply reads the data off the currently open file(s), and switches to the next file(s) when reaching EOF.The main challenge in this implementation is to find a consensus between the headers of the multiple
.tckfiles. The proposed implementation mimicks the strategy currently found intckedit, namely:countandtotal_count;"variable"in case of conflict.In addition, the proposed consensus fails if the datatypes varies across files.
Limitations
The intention behind the changes introduced is to avoid unnecessary merge operations, and to provide a seamless capability to handle multiple tracks sources in input. This does not apply to the output;
.lstfiles will not be recognised as output arguments, and any output will still be written to a single file (as before).This can be troublesome when the output of a command is meant to be used as the input to a subsequent command. For example with the output weights from
tcksift2passed as the-tck_weights_inoption oftck2connectome. In that case, at present, the output weights must be manually split into as many.tckfiles used (i.e. the lines of the.lstfile used withtcksift2); and another.lstfile should be created listing those new weights files. This is relatively easy to implement in Python, and I would be happy to provide an example if needed.Alternatively, a split-output behaviour could potentially be implemented within the
Writerclass, by specifying output names within an.lstfile as well (although this might not be relevant for all commands, and implementing a distinction might be cumbersome).Possible future work
The consensus implemented in
tckeditshould be replaced with the new implementation intractography/file_base.The changes introduced make the implementations of
Tractography::Editing:LoaderandTractography::Mapping::Loadersomewhat redundant. I think these loader-classes should be merged into a single implementation, in order to assess whether or not they are really needed, given the new capabilities ofTractography::Reader.